Option Button Help , I'm a Gr.10 Student

Dec 20, 2006 0 Replies

Hey, I'm a Grade 10 student for VB 6.0, For my project i am making a quiz. I can check if the answer is correct or wrong automatically and assing points and deduct points with list boxes. so the user click on a list box to answer a questions. to have more variety i wanted to have option button and check boxes to be available for the user to use while answering the questions. this will alllow me to change the nature of my questions.



intRandom will go upto 2 'then it will choose one of the 2 questions to ask the usre



Select Case intRanom Case 1 lblQuestions.caption = "Who is in that picture?" picPerson (app.Path.. CONTINUED... Case 2 lblQuestions.caption = "What countries flag is that?" picPerson (app.Path.. CONTINUED... End Select



that will allow it to enter the question in the label and make it random. so if int random is 1 than it will show the first questions and it will show a picture in a picPerson Picture Box. So for the answer of this i will say if the first question pops up the answer should be option button 1 or what ever option button i want to choose.


NOW THE QUESTION IS HOW WILL it test if the asnwer is correct.. read below its my actual code for testing for the correct answer with list boxes please help me asap.. thanks If you still dont understand my question please feel free to contact me snipped-for-privacy@gmail.com


----------------------------------------------------------------------------------------------------------------------------------------------- Private Sub Form_Load()



Randomize



intRandom = Int(Rnd * 3) + 1



lblScore.Caption = "Your Current Score is :" & intScore


Select Case intRandom Case 1 imgActor.Picture = LoadPicture(App.Path & "\Elvis.jpg") lstAnswer.AddItem ("Elvis Presley") lstAnswer.AddItem ("Geroge Lucas") lstAnswer.AddItem ("Hobo Joe") Case 2 imgActor.Picture = LoadPicture(App.Path & "\Hamza.jpg") lstAnswer.AddItem ("Jackie Chan") lstAnswer.AddItem ("Hamza Hamid") lstAnswer.AddItem ("Avril Lavigne") Case 3 imgActor.Picture = LoadPicture(App.Path & "\JessicaAlba.jpg") lstAnswer.AddItem ("Jackie Chan") lstAnswer.AddItem ("Owen Wilson") lstAnswer.AddItem ("Jessica Alba") End Select



End Sub



Private Sub lstAnswer_Click() Dim strAnswer As String



strAnswer = lstAnswer.List(lstAnswer.ListIndex)



Select Case intRandom Case 1 If strAnswer = "Elvis Presley" Then MsgBox "Correct Answer!" intScore = intScore + 10 lblScore.Caption = "Your Current Score is :" & intScore Else MsgBox "Incorrect Answer" intScore = intScore - 5 lblScore.Caption = "Your Current Score is :" & intScore End If frmEntertainmentQ2.Hide Case 2 If strAnswer = "Hamza Hamid" Then MsgBox "Correct Answer!" intScore = intScore + 10 lblScore.Caption = "Your Current Score is :" & intScore Else MsgBox "Incorrect Answer" intScore = intScore - 5 lblScore.Caption = "Your Current Score is :" & intScore End If frmEntertainmentQ2.Hide Case 3 If strAnswer = "Jessica Alba" Then MsgBox "Correct Answer!" intScore = intScore + 10 lblScore.Caption = "Your Current Score is :" & intScore Else MsgBox "Incorrect Answer" intScore = intScore - 5 lblScore.Caption = "Your Current Score is :" & intScore End If frmEntertainmentQ2.Hide End Select



End Sub



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required