VB 2005 Form data append to text file help

I am writing a program that lists data from an access table and allows a user to update the data. When the user uses the form to update the table with new data, I want to be able to copy that new data to a txt file and append the data already in the file. The data in the file looks something like this:

Data1[
Data2[
Data3[

I want the data from text fields in the form placed in the corresponding field in the text file just after the [ character. It has to be simple. I just cannot figure out how to take the data in the text fields of the form and place them in the text file after the [ character. Any help is appreciated.

Comments

  • : I am writing a program that lists data from an access table and
    : allows a user to update the data. When the user uses the form to
    : update the table with new data, I want to be able to copy that new
    : data to a txt file and append the data already in the file. The
    : data in the file looks something like this:
    :
    : Data1[
    : Data2[
    : Data3[
    :
    : I want the data from text fields in the form placed in the
    : corresponding field in the text file just after the [ character. It
    : has to be simple. I just cannot figure out how to take the data in
    : the text fields of the form and place them in the text file after
    : the [ character. Any help is appreciated.
    :


    this opens and appends to a file in vb6, you may need to modify for vb2005-


    'APPEND TO FILE
    Public Sub FileWrite(ByVal myString As String)

    Const myFile = "D:myFile.txt"
    Dim myFileNum As Integer, myText As String

    On Error GoTo ErrWrite

    myText = "Data[ " & myString
    myFileNum = FreeFile

    Open myFile For Append As myFileNum 'APPEND TO FILE
    Print #myFileNum, myText

    Xit:
    Close myFileNum
    Exit Sub

    ErrWrite:
    MsgBox Err.Description, vbExclamation, Err.Number
    Resume Xit
    End Sub
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion