Results 1 to 2 of 2

Thread: [RESOLVED] Track Four Values Placed Randomly

  1. #1

    Thread Starter
    Fanatic Member mateo107's Avatar
    Join Date
    Jan 2005
    Posts
    547

    Resolved [RESOLVED] Track Four Values Placed Randomly

    I've got four buttons. btnA, btnB, btnC, btnD

    I've got four "answers" that I'm going to be putting randomly as labels onto these four buttons. How would I assign them randomly and track which button 'got' the correct answer?

    something like this?

    Code:
    Dim value1 as String = "This is the correct Answer"
    Dim value2 as String = "This is wrong answer 1"
    Dim value3 as String = "This is wrong answer 2"
    Dim value4 as String = "This is wrong answer 3"
    
    'randomly place each of the four items as labels
    Dim correctAnswer as string = btnX '(in reality - would be A, B, C, or D)


    -Matthew-

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: Track Four Values Placed Randomly

    There are loads of instructions around on how to randomise items in a list, including two of my own threads in the VB.NET CodeBank, which you can access from my signature below. As for which represents the correct answer, you can use the Tag property of a control to store arbitrary data or, if you want to take it further, you could derive your own custom control from Button and add a Boolean property specifically for the purpose.

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