Question Save File Dialogue

david84

Member
Joined
May 6, 2010
Messages
20
Programming Experience
Beginner
This save file dialogue works fine except when they click save, the dialogue opens and then they close the dialogue. when they close it, my program crashes, every time. i'm using this to save it

VB.NET:
Dim sfd As New SaveFileDialog
        With sfd
            .Filter = "Text Documents (*.txt)|*.txt|PHP (*php.*)|*php.*"
            .FilterIndex = 1
            .Title = "Save File As"
        End With
        sfd.ShowDialog()
        IO.File.WriteAllText(sfd.FileName, Textbox.Text
 
That's probably because you're not checking for Cancel or anything before writing the text out

If sfd.ShowDialog() <> DialogResult.Cancel Then ... write the text
 
That's probably because you're not checking for Cancel or anything before writing the text out
You are probably right, but just to be sure....

What is the error message you get when it "crashes"?
 
It's the opposite of "=", it means "Equals Not". In c/c++/Java/c# the "equals not" is "!=" and "<>" is vb's syntax for it. vb can also have "Not Something = SomethingElse" to achieve the same result.
 
Back
Top