Results 1 to 9 of 9

Thread: Listbox help

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    62

    Listbox help

    Ok so lets say a listbox has

    Code:
    ________________________
    |Hi                                  |
    |Bye                                |
    |                                     |
    |                                     |
    |                                     |
    |                                     |
    ----------------------------
    How would I make it so that when my command button is clicked the textbox (text1) gets hi, and another command button is clicked, and another textbox(text2) gets bye, and so on?

  2. #2

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    62

    Re: Listbox help

    Erm, no one? =/

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Listbox help

    You could create an array of Command Buttons and an array of TextBoxes. And in the code, you could have something like:

    VB Code:
    1. Private Sub Command1_Click(Index As Integer)
    2.     text1(Index).Text = list1.List(Index)
    3. End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    62

    Re: Listbox help

    There is a compile error saying procedure declaration does not match description of event or procedure having same name and highlights
    Private Sub Command1_Click(Index As Integer)

  5. #5
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Listbox help

    You need to make a control array of the Textboxes and the Command Buttons by setting their Index properties to "0".

    Here's a quick example I made.
    Last edited by DigiRev; Mar 26th, 2007 at 02:55 AM.

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    62

    Re: Listbox help

    How would I make this code, go through all of the lines of the list?

    VB Code:
    1. Private Sub Command2_Click(Index As Integer)
    2.     Dim stuff As String
    3.     Dim HTML As String
    4.     RW(0).SetProxy List1.List(0)
    5.     HTML = RW(0).Request("GET", "http://www.ipchicken.com/")
    6.     stuff = GetBetween(yourIP, "<b>", "<br>")
    7.     HTML = stuff
    8.     If stuff = yourIP Then
    9.     ' yourIP is a textbox, with the real IP
    10.     List2.AddItem List1.List(0) & " doesn't work."
    11.     Else
    12.     List2.AddItem List1.List(0) & " works!"
    13.     End If
    14. End Sub

    Basically RW is a winsock wrapper. Now this is a proxy checker (this isn't whole code). So how would I make it so it goes through the whole list, checking all of the IPs?

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    62

    Re: Listbox help

    Also, how would you make a line on a listbox be copyable, but not editable?

  8. #8

  9. #9
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Listbox help

    so you mean to say, you have a listbox which contains IP address and you want to check all the IP address, if so, use a loop and scan thru the list like this...
    VB Code:
    1. Dim i As Integer
    2. For i = 0 To List1.ListCount - 1
    3.     RW(0).SetProxy List1.List(i)
    4.     '....and so on
    5. Next
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


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