Hello again,
I'm still working on my game, and now I'm running into a situation where I am using 4 radiobuttons in a groupbox for the answers, as each question changes the text of the radiobutton changes and along with it the correct answer. I want to be able to have the user click on the button they think is the answer and have it record a correct or incorrect answer and then call the sub that generates the next question.

I know I can do a click event for a Radiobutton and have it be it's own sub, but since these Radiobuttons are dynamic I don't see how that would work.

Is there a way to do make clicking a radiobutton cause an event without it having a checkedchanged sub?

You will need to create the sub for the click and then add the handler on runtime.

Example:

AddHandler RadioButton1.Click, AddressOf RBC

Private Sub RBC(sender As Object, e As EventArgs)
    'Place code here
End Sub

First. Dude you're awesome, thanks for always responding to my silly questions :)

Second. Will that allow me to have the code for the radiobuttons change so the answers are different?

something like:

If ARadioButton.checked = False Then
    wrongAnswer()
Else If BRadioButton.checked = True Then
    correctAnswer()
Else If CRadioButton.checked = Fase Then
    wrongAnswer()
End If

that changes to

If ARadioButton.checked = True Then
    correctAnswer()
Else If BRadioButton.checked = True Then
    wrongAnswer()
[etc...]

during runtime?

Or after I create the sub, would I put a line into each questions method (q1, q2) that has the addhandler?

Yep, if you want to check all of the radio buttons at once (Only allowing one answer/click) you will want to do the follwing:

AddHandler RadioButton1.Click, AddressOf RBC
AddHandler RadioButton2.Click, AddressOf RBC
AddHandler RadioButton3.Click, AddressOf RBC
AddHandler RadioButton4.Click, AddressOf RBC

Then place the IF code in the RBC Sub, checking for which radio button was clicked.

To check which control sent the action, make use of the sender object.

Awesome thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.