VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Random Number Incrementation

by Mitul Bhavsar (1 Submission)
Category: Encryption
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 19th September 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Random Number Incrementation

API Declarations


Dim Num2 As Integer
Dim Con As Integer


Rate Random Number Incrementation



Private Sub Command1_Click()
Static RefCon
Text1.Enabled = True
Label3.Visible = False
RefCon = Label5.Caption
Randomize
Num1 = Int((20 * Rnd) + 1)
Num2 = Int((20 * Rnd) + 1)
Label1.Caption = Num1
Label2.Caption = Num2
Label3.Caption = Num1 * Num2
Text1.SetFocus
Text1.Text = ""
Label4.Caption = ""
Con = RefCon + 1
RefCon = Con
Label5.Caption = RefCon
Form1.Caption = "Your Question No :---   " & RefCon
If RefCon = 10 Then
Command1.Enabled = False
Command3.Enabled = True
Timer1.Enabled = False
Exit Sub
End If
Command1.Enabled = False
End Sub

Private Sub Command3_Click()
Dim k As Integer
k = MsgBox("Do U Want to Give another Test ?", vbYesNo, "MituL")
If k = 6 Then
Form1.Refresh
Command1.Enabled = True
Label1.Caption = ""
Label2.Caption = ""
Text1.Text = ""
Command3.Visible = False
Label9.Caption = ""
Label10.Caption = ""
Label6.Caption = 0
Label5.Caption = 0
Form1.Caption = "Click on Question Button to Start . . ."
Timer1.Enabled = True
Else
End
End If
End Sub

Private Sub Label4_Click()
Label3.Caption = " Correct Answer        " & Label3.Caption
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If Label5.Caption <= 10 And KeyAscii = 13 Then
Command1.Enabled = True
Command1.SetFocus
Text1.Enabled = False
Else
End If
End Sub

Private Sub Text1_LostFocus()
Static Right As Integer
Static Wrong As Integer
If Val(Text1.Text) = Label3.Caption Then
Label4.Caption = "True..."
Right = Right + 10
Else
Label4.Caption = "False..."
Wrong = Wrong + 1
Right = Right - 10
End If

If Label4.Caption = "False..." Then
Label3.Visible = True
Else
Label3.Visible = False
End If
Command1.Enabled = True
If Label5.Caption <> 10 Then
Command1.SetFocus
Else
End If

If Label5.Caption = 10 Then
Command1.Enabled = False
Command3.Enabled = True
Label9.Caption = "Your Score :-  " & Right
Label10.Caption = "Wrong Ans :-  " & Wrong
Exit Sub
End If

End Sub

Private Sub Timer1_Timer()
Dim Nt1
Nt1 = Label6.Caption
Nt1 = Nt1 + 1
If Nt1 >= 100 Then
MsgBox " Your Time Up..." & vbCrLf & " Punishment : U won't get your score ", , "MituL"
Timer1.Enabled = False
End
End If
Label6.Caption = Nt1
End Sub


Download this snippet    Add to My Saved Code

Random Number Incrementation Comments

No comments have been posted about Random Number Incrementation. Why not be the first to post a comment about Random Number Incrementation.

Post your comment

Subject:
Message:
0/1000 characters