CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Option Buttons

  1. #1
    Guest

    Option Buttons

    l want to create a program that contains six question with four options button, on each of them(like a multi chose). But the problem is that l want to store 20 store questions & select six of these at random. How this done?


  2. #2
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Re: Option Buttons

    Use RANDOMIZE function to randomize your 20 questions. Other then taht please explain a little bit more of what exactly you want


  3. #3
    Guest

    Re: Option Buttons

    Off the top of my head...


    public function SelectRandomQuestions()

    dim question as integer, x as integer, qu(1 to 6) as integer, y as integer
    dim q(1 to 6) as string
    randomize

    for x = 1 to 6 'Pick six questions
    question = rnd*20 'randomly out of 20.

    if question = 0 then question = 1

    for y = 1 to 6 'no duplicates...
    if qu(y) = question then
    do while qu(y) <> question
    doevents
    question = rnd * 20
    loop
    end if
    next y

    qu(x)=question

    select case question
    case 1
    q(x)="Question 1"
    case 2
    q(x)="Question 2"
    case 3
    q(x)="Question 3"
    case 4
    q(x)="Question 4"
    case 5
    q(x)="Question 5"
    case 6
    q(x)="Question 6"
    case 7
    q(x)="Question 7"
    case 8
    q(x)="Question 8"
    case 9
    q(x)="Question 9"
    case 10
    q(x)="Question 10"
    case 11
    q(x)="Question 11"
    case 12
    q(x)="Question 12"
    case 13
    q(x)="Question 13"
    case 14
    q(x)="Question 14"
    case 15
    q(x)="Question 15"
    case 16
    q(x)="Question 16"
    case 17
    q(x)="Question 17"
    case 18
    q(x)="Question 18"
    case 19
    q(x)="Question 19"
    case 20
    q(x)="Question 20"
    end select
    next x

    end function




    There! You'll have six random questions - q(1) ... q(6).

    -Rich Morgan
    [email protected]



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

Featured