Results 1 to 8 of 8

Thread: How can I change the capacity of a listbox?????

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2

    How can I change the capacity of a listbox?????

    I'm doing a quiz program. And dont wanna use to much forms, so how can i make the capacity of the listbox change after someone chose the good anwser. Thanx

    Ps: code sample would be nice

    Thanx,

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    What do you mean by "change"?

    Do you want to clear out all entries except the correct answer?

  3. #3
    Addicted Member
    Join Date
    Mar 2001
    Posts
    157
    Changing the height will change the no. of entries you can see at once.

  4. #4
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    To clear all the items except the right answer.

    [Highlight=VB]
    dim s as string
    dim i as integer

    s = "Correct Answer"

    for i = 0 to list1.listcount-1
    if ucase(list1.list(i)) <> ucase(s) then
    list1.removeitem(i)
    end if
    next i

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    These are both things that I thought of, but I wasn't, and still am not, sure exactly what the question is.

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2001
    Posts
    2
    Look an example:

    1) what is 5+2

    3
    4
    7


    If list1.text = "7" then
    label1.caption = " 2) what is 7-8" 'thats the next qeustion'


    Now my qeustion is, is there a code to change the answers in the listbox, the same what I did whit the qeustion in label1.

  7. #7
    Frenzied Member vbgladiator's Avatar
    Join Date
    May 2001
    Posts
    1,950
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     If List1.List(List1.ListIndex) = "3" Then
    5.         Label1.Caption = "2) What is 2 + 2"
    6.         List1.Clear
    7.         List1.AddItem "5"
    8.         List1.AddItem "8"
    9.         List1.AddItem "4"
    10.     Else
    11.         Exit Sub
    12.     End If
    13. End Sub
    14.  
    15. Private Sub Form_Load()
    16.     Label1.Caption = "1) What is 1 + 2"
    17.     List1.AddItem "1"
    18.     List1.AddItem "5"
    19.     List1.AddItem "3"
    20. End Sub

  8. #8
    Addicted Member
    Join Date
    Sep 2001
    Location
    UK
    Posts
    136
    That looks good i'll make a prog like that myself when i'm bored.

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