Results 1 to 3 of 3

Thread: Form Exiting

  1. #1

    Thread Starter
    Addicted Member Rally2000's Avatar
    Join Date
    Dec 2003
    Location
    Central USA
    Posts
    134

    Question 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

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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
  •  



Click Here to Expand Forum to Full Width