|
-
Dec 31st, 2003, 12:48 AM
#1
Thread Starter
Addicted Member
Form Exiting
Hi Guys!
Question: I have the following code in my WordPad.
Code:
If bEdited = True Then
Dim check As MsgBoxResult
check = MsgBox("Text has not been saved. Save changes?", MsgBoxStyle.YesNo)
If check = MsgBoxResult.Yes Then
If tb1.Text <> "" Then
sfd.Filter = "Text Files (*.txt)|*.txt"
sfd.FilterIndex = 1
sfd.ShowDialog()
If sfd.FileName <> "" Then
FileOpen(1, sfd.FileName, OpenMode.Output)
PrintLine(1, tb1.Text)
FileClose(1)
Me.Text = sfd.FileName
End If
End If
End If
If check = MsgBoxResult.No Then
Application.Exit()
End If
End If
bEdited = False
Application.Exit()
This Code works OK but does not do what I would like it to do, as you can see it will bring up the save dialog any time something was changed. Now, if the user created a new file that would be acceptable, but if the user has made changes to an existing File it should only prompt (Yes/No) and if “Yes”save the File automatically.
How would I go about doing this??
Thanks!
Code:
Dim R1 As Fast
Dim Kawasaki As crap
Dim rash As necessary
If Kawasaki onRoad = True Then
R1.runoverKawasaki
Kawasaki = rash
-
Dec 31st, 2003, 08:47 AM
#2
Sleep mode
What if you try having two boolen variables . One for new file creation and the other one for editing files . Then you would check for these values with two if blocks .
-
Dec 31st, 2003, 09:46 AM
#3
PowerPoster
Hi,
"but if the user has made changes to an existing File it should only prompt (Yes/No) and if “Yes”save the File automatically.
How would I go about doing this??"
When the file is originally opened for editing, store the path (in a variable or textbox etc.) If it is a new file, make that variable (or etc.) blank. In your closing code check for the contents of that variable (or etc.) with another nested If clause and act accordingly, bypassing the FileSaveDialog box if necessary.
Hope that helps,
taxes.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|