Results 1 to 3 of 3

Thread: How put txt file lines into txtbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    2

    Question How put txt file lines into txtbox

    Hello

    I have a little problem with VisualBasic 6.0.
    I try to read data from txt file and put into txtBox.

    So in case i fill fields (Name, Title,Phone,Address) and press Add then data will save in c:/txt.txt on the first 4 lines. If i do it again then data will save for following 4 lines in C:/Text.txt and so on.
    I have already done a part where i can add data into txt file

    VisualBasic code:

    Private Sub Add_Click()
    Open "C:\Text.txt" For Append As #1
    Print #1, txtName.Text
    txtName.Text = ""
    Print #1, txtTitle.Text
    txtTitle.Text = ""
    Print #1, txtPhon.Text
    txtPhone.Text = ""
    Print #1, txtAadress.Text
    txtAadress.Text = ""
    Close #1
    End Sub

    My questions are.

    How can i view txt file lines in the txtboxes(txtName, txtTitle,txtPhone,txtAddress). If i will press View i will have to see the first 4 lines and if i do it again i will see 4 more lines and so on.
    When i will press delete how can i delete the first 4 lines... and the following 4 lines and so on in the text file

    VisualBasic form Object name C:/Text.txt

    Name : ______.........txtName..........1 Marek ..........-Name
    Title:________..........txtTitle............2 Mr.................-Title
    Phone:_______....... txtPhone.........3 052454102...-Phone
    Address: _____........txtAddress.......4 Home...........-Address
    .........................................................5 Kuslap..........-Name
    Add............................cmdAdd...........6 Mr................-Title
    View...........................cmdVie............7 521545566...-Phone
    Delete........................cmdDelete.......8 jungle..........-Address

    Pleace Help me! I need solution!
    All the best
    Last edited by tultsik; Apr 22nd, 2004 at 05:45 PM.

  2. #2
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    See if this thread helps you progress

    http://www.vbforums.com/showthread.p...hreadid=287389

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Location
    India
    Posts
    16
    Can you clearly mention what kind of result do you want
    Any how i m sending you a code

    check it out if this can help you out

    Private Sub cmdAdd_Click()
    Open "C:\hemant'sdatabank\hemant.txt" For Append As #1
    Print #1, StrConv(txtname.Text, vbProperCase) & " " & StrConv(txttitle.Text, vbProperCase) & " " & txtphone.Text & " " & StrConv(txtaddress.Text, vbProperCase)
    txtname.Text = ""
    txttitle.Text = ""
    txtphone.Text = ""
    txtaddress.Text = ""
    Close #1
    End Sub


    Private Sub cmdView_Click()
    Dim line As String
    Open "C:\hemant'sdatabank\hemant.txt" For Input As #1
    Do While Not EOF(1)
    Input #1, line
    txtview.Text = txtview & line & vbCrLf
    Loop
    Close #1
    End Sub

    May be you want to display the details in seperate text
    then for that use split function
    cliff

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