i randomized the numbers ranging 1-20, it generates 2 numbers for label1 and label2 after clicking the command1 button. i created a textbox and another command button for checking if ever the to labels are ADDED, the answer in the textbox should match the right answer.. it will be activated by clicking the command2 button(Checking)... I was planning to make a quiz type program... please help me...

here are the codes... i just nid the conditions on how to make the checking if ever the two labels are added the answer written in the textbox should match the right answer.

Private Sub Form_Load()
Randomize
End Sub

Private Sub Command1_Click()Dim MyValue1 As Integer
Dim MyValue2 As Integer


MyValue1 = Int((20 * Rnd) + 1)
MyValue2 = Int((20 * Rnd) + 1)

Label1.Caption = MyValue1
Label2.Caption = MyValue2

End Sub

Private Sub Command2_Click()
'this is the part where i nid to have the right codes...

Dim aa As Integer
Dim bb As Integer

aa = Label1.Caption
bb = Label2.Caption

If MyValue2 + MyValue1 = True Then
Picture1.Cls
Label3.Caption = "correct"

Else
Label3.Caption = "wrong"


End If


End Sub

Hi,
Make few changes in your coding.
First,

Private Sub Command1_Click()
   Dim MyValue1 As Integer
   Dim MyValue2 As Integer
  
  [B]Randomize[/B]

   MyValue1 = Int((20 * Rnd) + 1)
   MyValue2 = Int((20 * Rnd) + 1)
End Sub

Second,

Private Sub Command2_Click()

   Dim aa As Integer
   Dim bb As Integer
   [B]Dim Result As Integer
   
   aa = Val(Label1.Caption)
   bb = Val(Label2.Caption)
   Result = Val(Text1.Text)
   
   If aa + bb = Result Then[/B]
      Picture1.Cls
      Label3.Caption = "correct"
   Else
      Label3.Caption = "wrong"
   End If
End Sub
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.