Results 1 to 13 of 13

Thread: need help fixing it?

  1. #1

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Cool need help fixing it?

    Hi
    Can you all help me fix it?
    It done not print to the Listbox
    Dim A As String
    Private Sub Command1_Click()
    End
    End Sub

    Private Sub List1_Click()
    Open "C:\pos\bob\bob.txt" For Input As #1
    Input #1, A
    Close #1
    List1.AddItem A
    End Sub
    Last edited by dos5731; Apr 3rd, 2005 at 12:24 PM.

  2. #2
    Addicted Member
    Join Date
    Mar 2005
    Posts
    238

    Re: need help fixing it?

    Ummm... did u define a? like
    a = blah blah?
    The Tempest Shall Never Die.

  3. #3

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Re: need help fixing it?

    No!!!

  4. #4
    Addicted Member
    Join Date
    Mar 2005
    Posts
    238

    Re: need help fixing it?

    Then why don't you? lol
    The Tempest Shall Never Die.

  5. #5

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Re: need help fixing it?

    I did it and it dose not work.

  6. #6
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Re: need help fixing it?

    How does bob.txt look like? If you're reading a string, you need to have it between quotes. Otherwise use "Line Input", binary, or the FileSystem object.

  7. #7

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Cool Re: need help fixing it?

    bob.txt
    bob
    bob

  8. #8
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Re: need help fixing it?

    For what you're doing, you'd need:

    __________________
    "bob"
    "jack"
    "some other guy"
    __________________

    Or use "Line Input" instead of "Input"

  9. #9
    Hyperactive Member wiccaan's Avatar
    Join Date
    Apr 2004
    Location
    127.0.0.1
    Posts
    475

    Re: need help fixing it?

    You could use this code as well. Put this in a module:

    Code:
    Public Sub TextToList(WhatList As ListBox, TextFile$)
    Rem Makes a .txt file from a listbox
    On Error GoTo FartK
    Dim X%
    X% = FreeFile
    Open TextFile$ For Input As #X
    While Not EOF(X)
    Input #X, sText$
    DoEvents
    WhatList.AddItem sText$
    Wend
    Close #X
    Exit Sub
    FartK:
    Exit Sub
    End Sub
    Then on your forum have 2 command buttons and 1 listbox. All default names.

    In Command1 have:

    Code:
    Private Sub Command1_Click()
        TextToList List1, "C:\pos\bob\bob.txt"
    End Sub
    And in Command2 since you wanted oen to end the program:

    Code:
    Private Sub Command2_Click()
       End
    End Sub
    The above function will read a textfile on each line and put it into a Listbox of your choice. By pressing the Command1 button, you will open the textfile, and add all the lines in it into the Listbox on their own line, just as they were in the txt file.
    If my post was helpful please rate it

  10. #10

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Cool Re: need help fixing it?

    new code

    Option Explicit
    Dim g
    Dim h

    Private Sub Command1_Click()
    End
    End Sub

    Private Sub List1_Click(Index As Integer)
    Open "C:\pos\bob.txt" For Input As #1
    Line Input #1, g
    Close #1
    For X = 1 To 1
    List1.AddItem g
    Next X
    End Sub

  11. #11
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: need help fixing it?

    VB Code:
    1. Dim A As String
    2.  
    3. Private Sub Command1_Click()
    4.     End
    5. End Sub
    6.  
    7. Private Sub List1_Click()
    8.     Open "C:\pos\bob\bob.txt" For Input As #1
    9.     Input #1, A
    10.     Close #1
    11.     List1.AddItem A
    12. End Sub


    You havn't assigned A a value. Therefore your file will be empty, plus the Command1_Click procedure has an error in it, it doesn't need to be there.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12

    Thread Starter
    Banned
    Join Date
    Mar 2005
    Posts
    26

    Cool Re: need help fixing it?

    It is not working for me.
    Attached Files Attached Files

  13. #13
    Banned
    Join Date
    Mar 2005
    Posts
    23

    Re: need help fixing it?

    he got it work by ueing a Commandbtton.
    Last edited by crocker; Apr 3rd, 2005 at 10:41 PM.

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