Results 1 to 2 of 2

Thread: Combo question

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Angry Combo question

    I have a combo box in which i have inputed a text file. When I hit a commmand button it generates a random number and it selects from the list of the combo box the value of that number. When I generate a new number it works OK but sometimes it show the text value as if it were
    VB Code:
    1. Combo1.Text = ""
    even though it doesn't exist as an item in the list. And of course this messes up my program...Any ideas?

    Thanks in advance...


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    VB Code:
    1. '===============================================
    2. 'Rand - Return a random number in a given range.
    3. '
    4. 'Parameters:
    5. '  Low  - The lower bounds of the range.
    6. '  High - The upper bounds of the range.
    7. '
    8. 'Returns:
    9. '  Returns a random number from Low..High.
    10. '===============================================
    11.  
    12. Public Function Rand(ByVal Low As Long, _
    13.                      ByVal High As Long) As Long
    14.   Rand = Int((High - Low + 1) * Rnd) + Low
    15. End Function

    Try using this function when to get a random number. Coding should look something like:

    Dim intRandomNumber As Integer
    intRandomNumber = Rand(0, ListboxName.ListCount - 1)

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