Results 1 to 5 of 5

Thread: [Visual Basic 6] Text file won't load

  1. #1

    Joined
    Dec 2011
    Posts
    843
    Pronouns
    she/her
    Userbars
    3
    Thanks
    313
    Thanked
    346/213
    DL/UL
    34/2
    Mentioned
    179 times
    Time Online
    1d 19h 11m
    Avg. Time Online
    N/A

    [Visual Basic 6] Text file won't load

    Code:
    Private Sub Command11_Click()
    
        Dim strFile As String
        strFile = SelectFileToLoad(CD)
        If Len(strFile) > 1 Then
            Call TextFileToList(strFile, ListofUsernames)
        Else
            MsgBox "Please Select a File!", vbInformation, "Error!"
        End If
    
    End Sub
    I have a text file with a list of user names, and yet it won't load into my list box 'ListofUsernames'

  2. #2

    Joined
    Dec 2011
    Posts
    262
    Thanks
    22
    Thanked
    106/68
    DL/UL
    22/0
    Mentioned
    74 times
    Time Online
    N/A
    Avg. Time Online
    N/A
    I have a handy class I use for listboxes. Someone gave it to me long ago on SD.

    (you need an account to see links)

    Add it to the project.
    Add the Microsoft Common Dialog Control Component 6.0. (Add it to the form and name it 'comDia')

    Add this code to the very top of your code.
    Code:
    Dim clsList As New clsList
    Add this code to your Form_Load
    Code:
    clsList.BindList yourlistbox
    And for loading and saving, use these, you can change them around a little bit.
    Code:
    Private Sub cmdLoad_Click()
    On Error GoTo ErrHand
        With comDia
            .DialogTitle = "Load List"
            .Filter = "Text Files|*.txt"
            .CancelError = True
            .ShowOpen
            clsList.LoadListFromFile .FileName
        End With
    ErrHand:
    End Sub
    
    Private Sub cmdSave_Click()
    On Error GoTo ErrHand
        With comDia
            .DialogTitle = "Save List"
            .Filter = "Text Files|*.txt"
            .CancelError = True
            .ShowSave
            If Dir(.FileName) <> "" Then
                ans = MsgBox("The file " & .FileTitle & " already exists." & vbCrLf & _
                "Are you sure you want to overwrite it?", vbYesNo, "Confirm Overwrite")
                If ans = vbNo Then Exit Sub
            End If
            clsList.SaveListToFile .FileName
        End With
    ErrHand:
    End Sub
    End Sub

  3. #3

    Joined
    Dec 2011
    Posts
    843
    Pronouns
    she/her
    Userbars
    3
    Thanks
    313
    Thanked
    346/213
    DL/UL
    34/2
    Mentioned
    179 times
    Time Online
    1d 19h 11m
    Avg. Time Online
    N/A
    @(you need an account to see links)

    Runtime error when the form loads.... should I make any special changes to this
    Code:
    clsList.BindList yourlistbox
    ?


    Like perhaps
    Code:
    clsList.BindList list1
    ?

  4. #4

    Joined
    Dec 2011
    Posts
    262
    Thanks
    22
    Thanked
    106/68
    DL/UL
    22/0
    Mentioned
    74 times
    Time Online
    N/A
    Avg. Time Online
    N/A
    Yea change 'yourlistbox' to whatever you name your listbox.

  5. #5
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,722
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 5h 25m
    Avg. Time Online
    3h 13m
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  6. The Following User Says Thank You to j03 For This Useful Post:

    Ryan~ (02-12-2012)

Posting Permissions

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