Results 1 to 3 of 3

Thread: Totally confused This is not for School but for personal learning

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Calgary,Alberta, Canada


    I have a list of text files in a folder called MovieRentals. The File names are stored like Phone Numbers (555)-555-5555
    when the program starts you are prompted to enter a phone number. i cannot figure out how to access the files and retrive the information in the files and put them into textBoxes this code is a test that i am running not the actual program can some one tell me what's wrong with it or show me a example that works I known parts of the code is wrong but not sure how to fix it
    thxs in advance
    last name
    phone number

    Option Explicit
    Dim strFileName As String
    Dim strMember As String
    Dim strNam As String
    Dim intFreeFile As Integer

    Private Sub Command1_Click()
    txtMember = strFileName
    strFileName = Dir("d:\MovieRental")
    intFreeFile = FreeFile

    Open strFileName For Append As intFreeFile
    Line Input #intFreeFile, strMember
    Line Input #intFreeFile, strNam
    Loop Until (EOF)
    Close #intFreeFile
    End Sub
    Private Sub Pass_Values()

    txtText1 = strMember
    txtText2 = strNam
    End Sub

    [This message has been edited by Jessie (edited 11-30-1999).]

  2. #2
    Lively Member
    Join Date
    Jun 1999


    You should open the file for "input" NOT "append".

    Append sets you to the end of the file,input sets you to the begining of the file.

    Also in the strFileName, include the extention of the file
    ie: "D:\MovieRental.Txt"

    Also everytime you loop thrugh the code reading in a line from the file, you are overwriting the previously read line without storing the information.

    Try something like
    Create an array of TextBoxes called
    txtMyTextBox, then use the following code

    Private strLineInfo() as String

    intLC = 0
    Open strFileName for Input as #1
    Do While NOT EOF(1)
    ReDim Preserve strLineInfo(intLC)
    Input #1,strLineInfo(intLC)
    intLC = intLC + 1
    Close #1

    For n = 0 to intLC
    txtMyTextBox(n).Text = strLineInfo(n)
    Next n

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Calgary,Alberta, Canada


    Thxs SteveS i am learning Vb at home sometimes it gets frustrating do nothing but reading to find the answers and when you think that you find them the code doesn't work the way you think it should
    regards Jessie

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