I want to save Text box values in VB and retrieve.If you having any sample code please help me

Recommended Answers

All 2 Replies

Here's a really simple example to save/load a text box's text:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    ' Save a text box's text
    Dim FileName As String = "C:\test.txt"

    My.Computer.FileSystem.WriteAllText(FileName, TextBox1.Text, False)

  End Sub

  Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    ' Load a text box's text
    Dim FileName As String = "C:\test.txt"

    TextBox1.Text = My.Computer.FileSystem.ReadAllText(FileName)

  End Sub

If you want to save/load more than one text box, you can concatenate text's as a single string with a proper separator character, or take a look what System.IO namespace has to offer.

HTH

to save the contents of a text box:
it depends if you are saving to a file or to a DBMS
for a DBMS like sql server, just get your connection strings right, then use this
textbox1.databingds(text, datasource, connectionstring)

try it yourself but if you cant then i'll send you a complete code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.