Results 1 to 5 of 5

Thread: Save button code in visual basic 2008

  1. #1
    Join Date
    Apr 2009
    Posts
    79

    Save button code in visual basic 2008

    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: 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

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Save button code in visual basic 2008

    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.

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Save button code in visual basic 2008

    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

  5. #5
    Join Date
    Aug 2009
    Posts
    1

    Re: Save button code in visual basic 2008

    Quote Originally Posted by Walby View Post
    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.
    What do you mean by an "interlink. I am trying to save data to an sql database and this looks like the code I need but do not understand the interlink requirement.

Similar Threads

  1. help on visual basic 2008
    By gladys_ny in forum Software Development
    Replies: 1
    Last Post: 18-03-2011, 04:25 AM
  2. How to save audio files in Visual Basic ?
    By jyothiststvla in forum Software Development
    Replies: 1
    Last Post: 19-02-2010, 06:22 AM
  3. Form Help in MS Visual Basic 2008!
    By NGV BalaKrishna in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 10:07 PM
  4. Error Code 1330 while installing Visual Basic 2008
    By Capers in forum Windows Software
    Replies: 2
    Last Post: 02-05-2009, 07:11 PM
  5. Visual Basic 2008 & VB.net Difference any?
    By samit in forum Software Development
    Replies: 4
    Last Post: 05-08-2008, 07:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,298,960.97919 seconds with 17 queries