Click here to Skip to main content
15,887,135 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionequivalent of string.contains(vs2005) in vs2003. Pin
bishwambhar_sen15-Mar-09 1:31
bishwambhar_sen15-Mar-09 1:31 
AnswerRe: equivalent of string.contains(vs2005) in vs2003. Pin
N a v a n e e t h15-Mar-09 3:50
N a v a n e e t h15-Mar-09 3:50 
Questionsetting DropDownList value Pin
liz315-Mar-09 0:44
liz315-Mar-09 0:44 
AnswerRe: setting DropDownList value Pin
Expert Coming15-Mar-09 5:44
Expert Coming15-Mar-09 5:44 
General[Message Deleted] Pin
liz315-Mar-09 5:50
liz315-Mar-09 5:50 
GeneralRe: setting DropDownList value Pin
Expert Coming15-Mar-09 5:52
Expert Coming15-Mar-09 5:52 
GeneralRe: setting DropDownList value Pin
Expert Coming15-Mar-09 5:53
Expert Coming15-Mar-09 5:53 
Questionfile reading and writing problems Pin
StarTrekCafe15-Mar-09 0:31
StarTrekCafe15-Mar-09 0:31 
HI. got a project where you have a file menu, and you open a text file, then save the text file. and a exit menu item. now, if i click the open file menu item, it displays two text boxes, where you enter a name and phone number. but for some stupid reason, if i click the save menu item, i get a message saying the file needs to be open, and does not save the file? so what am i doing wrong and how to fix this? any help would be gretefully aprreciated. will post the code below. cheers Marvin.

'Program: Ch11 Open and Write File
'Programmer: Marvin Hunkin
'Date:Saturday March 7 2009
'Description: Allow the user to enter names and phone numbers and
' save them in a file.


Imports System.IO


Public Class frmCh11OpenAndWriteFile


' Declare module-level variable.

Dim PhoneStreamWriter As StreamWriter






Private Sub menSaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menSaveToolStripMenuItem.Click


' Save the record to the file.


If PhoneStreamWriter IsNot Nothing Then ' Is the file open?

With Me


PhoneStreamWriter.WriteLine(.tbNameTextBox.Text)
PhoneStreamWriter.WriteLine(.tbPhoneTextBox.Text)

With .tbNameTextBox
.Clear()
.Focus()

End With

With .tbPhoneTextBox

End With


End With

Else ' File is not open
MessageBox.Show("You must open the file before you can save a record", _
"File Not Open", MessageBoxButtons.OK, MessageBoxIcon.Information)


End If




End Sub

Private Sub menOpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menOpenToolStripMenuItem.Click


' Open the file.


Dim dlgResponseDialogResult As DialogResult


' Is the file already open?

If PhoneStreamWriter IsNot Nothing Then
PhoneStreamWriter.Close()


End If


' Begin in the project folder.


dlgOpenFileDialog.InitialDirectory = "C:\" ' Display the File Open dialog box.


' Make sure that the user didn’t click the Cancel button.


If dlgResponseDialogResult <> DialogResult.Cancel Then


' Open the output file.


End If


End Sub

Private Sub menExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menExitToolStripMenuItem.Click


' Close the file and the form.


If PhoneStreamWriter IsNot Nothing Then ' Is the file open?

PhoneStreamWriter.Close()

End If
Me.Close()


End Sub
End Class
AnswerRe: file reading and writing problems Pin
Mustafa Ismail Mustafa15-Mar-09 4:00
Mustafa Ismail Mustafa15-Mar-09 4:00 
AnswerRe: file reading and writing problems Pin
Expert Coming15-Mar-09 5:45
Expert Coming15-Mar-09 5:45 
AnswerRe: file reading and writing problems Pin
StarTrekCafe15-Mar-09 16:04
StarTrekCafe15-Mar-09 16:04 
AnswerRe: file reading and writing problems Pin
StarTrekCafe15-Mar-09 18:06
StarTrekCafe15-Mar-09 18:06 
QuestionNot Gorogrian Calander In Asp.net Pin
Mohamed Ibrahim Omar15-Mar-09 0:25
Mohamed Ibrahim Omar15-Mar-09 0:25 
AnswerRe: Not Gorogrian Calander In Asp.net Pin
Mustafa Ismail Mustafa15-Mar-09 3:49
Mustafa Ismail Mustafa15-Mar-09 3:49 
General[Message Deleted] Pin
Mohamed Ibrahim Omar15-Mar-09 20:43
Mohamed Ibrahim Omar15-Mar-09 20:43 
GeneralRe: Not Gorogrian Calander In Asp.net Pin
Mohamed Ibrahim Omar15-Mar-09 20:43
Mohamed Ibrahim Omar15-Mar-09 20:43 
Questionvb mail project problems Pin
StarTrekCafe15-Mar-09 0:25
StarTrekCafe15-Mar-09 0:25 
AnswerRe: vb mail project problems Pin
Christian Graus15-Mar-09 9:59
protectorChristian Graus15-Mar-09 9:59 
Questiontickets Project Help Pin
StarTrekCafe15-Mar-09 0:11
StarTrekCafe15-Mar-09 0:11 
AnswerRe: tickets Project Help Pin
Christian Graus15-Mar-09 10:08
protectorChristian Graus15-Mar-09 10:08 
AnswerRe: tickets Project Help Pin
StarTrekCafe15-Mar-09 13:33
StarTrekCafe15-Mar-09 13:33 
AnswerRe: tickets Project Help Pin
StarTrekCafe15-Mar-09 13:35
StarTrekCafe15-Mar-09 13:35 
QuestionLogin Project Problems Pin
StarTrekCafe15-Mar-09 0:02
StarTrekCafe15-Mar-09 0:02 
AnswerRe: Login Project Problems Pin
Abhijit Jana15-Mar-09 2:13
professionalAbhijit Jana15-Mar-09 2:13 
GeneralRe: Login Project Problems Pin
Colin Angus Mackay15-Mar-09 3:05
Colin Angus Mackay15-Mar-09 3:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.