Results 1 to 3 of 3

Thread: text file question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    text file question

    Hi all,

    I have a question i was able to load a textbox value in the text file where text data = " " is . But i want another condition to execute ie.. if there is text box value i want to put value in Message data = " .text " and if not i want to replace it with another value.
    the file looks like this
    [ Text 1 ]
    text data = " "

    [text 2 ]
    message data = " "

    this is the code iam trying with

    Dim tmp As String
    Dim lines() As String
    Dim x As Integer
    Open "default.txt" For Binary As #1
    tmp = Space(LOF(1))
    Get #1, , tmp
    Close #1

    lines = Split(tmp, vbCrLf)
    For x = 0 To UBound(lines)
    If lines(x) = "[Text 1]" Then
    x = x + 1
    Exit For
    End If
    Next

    lines(x) = "Text Data = " & Trim(cusname.Text) & " " & Trim(phone.Text) & " " & Trim(txtitem.Text)

    Open "default.txt" For Output As #1
    For x = 0 To UBound(lines)
    Print #1, lines(x)
    Next
    Close #1

    can anyone help

  2. #2
    Addicted Member Cimperiali's Avatar
    Join Date
    Oct 2002
    Location
    Milan, Italy, Europe
    Posts
    188

    Re: text file question

    Seems as if Ini files could be fine for your purpouse. Or you could use
    Random files.
    If you still want to deal with it like strings, you can use the following
    example :
    Attached Files Attached Files
    Special thanks to some wonderful people,
    such as Lothar the Great Haensler, Aaron Young,
    dr_Michael, Chris Eastwood, TheOnlyOne ClearCode....

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    122

    Re: text file question

    Thanks a lot guys ,, i got it resolved.

    cheers!!!!!!!!!!!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width