I am looking for code which save the item selected from combo box and from check box, the value displayed after selection must be save after clicking save button. Can any one tell me the save button code in visual basic 2008.
Printable View
I am looking for code which save the item selected from combo box and from check box, the value displayed after selection must be save after clicking save button. Can any one tell me the save button code in visual basic 2008.
Code:Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal a As System.EventArgs) Handles but.Click
Dim filnam As String
Try
With SaveFileDialog1
.AddExtension = True
.CheckPathExists = True
.CreatePrompt = False
.OverwritePrompt = True
.ValidateNames = True
.ShowHelp = True
.DefaultExt = "txt"
.FileName = filename
.Filter = _
"Text files (*.txt)|*.txt|" & "All files|*.*"
.FilterIndex = 1
If .ShowDialog() = Windows.Forms.DialogResult.OK Then
My.Computer.FileSystem.WriteAllText(.Fil… txt1.Text, False)
End If
End With
Catch y As Exception
MsgBox(e.Message, MsgBoxStyle.Exclamation, M.Text)
End Try
End Sub
End Class
When you click on save button where the data want to go? If you to save data in data base then you need interlink,As far as saving the data (anywhere) you can research the Form_Close event, this is where you would put the code to save your data, then it will save it as the form is closing.
The code for save button in visual basic 2008 :
Code:Sub SaveToTextFile() Handles savebutton.Click
Dim objWriter As New StreamWriter( "save.txt" )
objWriter.Write( savetxt.Text )
objWriter.Close()
End Sub