PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Save upon close?-VBForums
Results 1 to 4 of 4

Thread: Save upon close?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Question Save upon close?

    well im having a bit of trouble doing this..... whenever i try, the save file dialog comes up when i hit No and same when I hit Cancel....

    Code:
    If My.Settings.SaveSTS = False Then
                    MsgBox("Do you wish to save your changes?", MsgBoxStyle.YesNoCancel)
                    If MsgBoxResult.Yes Then
                        If My.Settings.OnceSaved = True Then
                            Dim writer As New IO.StreamWriter(SaveName)
                            writer.Write(txtEdit.Text)
                            writer.Close()
                        Else
                            If sfdHTML.ShowDialog = DialogResult.OK Then
                                SaveName = sfdHTML.FileName
                                Dim writer As New IO.StreamWriter(SaveName)
                                writer.Write(txtEdit.Text)
                                writer.Close()
                                Me.Text = sfdHTML.FileName
                                lblFileName.Text = sfdHTML.FileName
                            End If
                        End If
                    ElseIf MsgBoxResult.No Then
                        e.Cancel = True
                        Me.Close()
                    ElseIf MsgBoxResult.Cancel Then
                        e.Cancel = False
                    End If
                Else
                    e.Cancel = False
                    Me.Close()
                End If
    please help me...

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,126

    Re: Save upon close?

    vb Code:
    1. dim result as MsgBoxResult = MsgBox("Do you wish to save your changes?", MsgBoxStyle.YesNoCancel)
    2. If result = MsgBoxResult.Yes Then
    3.  
    4. ElseIf result = MsgBoxResult.No Then
    5.  
    6. ElseIf result = MsgBoxResult.Cancel Then
    7.  
    8. End If

  3. #3
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,966

    Re: Save upon close?

    Hey,

    On a side note, rather than use MsgBox, you really should be using MessageBox. The code above would then change to inspect the returned DialogResult, rather than a MsgBoxResult.

    Gary

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    106

    Re: Save upon close?

    .pual. ur the best!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width