For those who have kids at home, have you ever experienced difficulties in teaching them mathematics? If you have, it could be due to many factors, one of them might be due to boredom. So, to make learning math more interesting, you might want to buy some educational softwares. This idea is great, but you have to depart with some of your dollars, and the programs might not be suitable. So, since you know VB, why not program one yourself? It will save you a lot of money. If you don't know how, then please take a look at my program.
In this children educational math game, I set three levels of difficulty. To generate the random numbers, I use the random function Rnd and the Interger Int function. Rnd will generate a random number between 0 and 1. By coming the Rnd function and the Int function, we can generate random integers. For example, let say Rnd =0.325, then Rnd * 0.325 and 10x0.325=3.25. Finally, Int(Rndx0.325)=3
|
The Design Interface |
The Run Time Interface |
|
|
|
The Codes
Dim num1 As Integer
Dim num2 As Integer
Dim intNumber As Integer
Private Sub score()
intNumber = intNumber + 1
End Sub
Private Sub begin()
intNumber = 0
Image1.Visible = False
Image2.Visible = False
Label6.Visible = False
Label5.Visible = False
Text3.Text = ""
If Option1.Value = True Then
n = 10
ElseIf Option2.Value = True Then
n = 100
ElseIf Option3.Value = True Then
n = 1000
End If
Randomize Timer
num1 = Int(Rnd * n)
num2 = Int(Rnd * n)
Text1.Text = num1
Text2.Text = num2
Text3.SetFocus
End Sub
Private Sub Command3_Click()
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Image1.Visible = False
Image2.Visible = False
Label6.Visible = False
Label5.Visible = False
End Sub
Private Sub Start_Click()
begin
End Sub
Private Sub text3_keyDown(keyCode As Integer, shift As Integer)
If keyCode = vbKeyNext Or keyCode = vbKeyDown Then
begin
End If
End Sub
Private Sub text3_keypress(keyAscii As Integer)
If (keyAscii = 13) And Val(Text3.Text) = Val(Text1.Text) + Val(Text2.Text) Then
Image1.Visible = True
Image2.Visible = False
Label5.Visible = True
Label6.Visible = False
score
total.Caption = Str$(intNumber)
ElseIf (keyAscii = 13) And Val(Text3.Text) <> Val(Text1.Text) + Val(Text2.Text) Then
Image1.Visible = False
Image2.Visible = True
Label5.Visible = False
Label6.Visible = True
Text3.Text = ""
End If
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Next_Click()
Image1.Visible = False
Image2.Visible = False
Label6.Visible = False
Label5.Visible = False
If Option1.Value = "true" Then
n = 10
ElseIf Option2.Value = "true" Then
n = 100
ElseIf Option3.Value = "true" Then
n = 1000
End If
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Randomize Timer
num1 = Int(Rnd * n)
num2 = Int(Rnd * n)
Text1.Text = num1
Text2.Text = num2
Text3.SetFocus
End Sub
Private Sub OK_Click()
If Val(Text3.Text) = Val(Text1.Text) + Val(Text2.Text) Then
Image1.Visible = True
Image2.Visible = False
Label5.Visible = True
Label6.Visible = False
score
total.Caption = Str$(intNumber)
Else
Image1.Visible = False
Image2.Visible = True
Label5.Visible = False
Label6.Visible = True
Text3.Text = ""
End If
End Sub
Private Sub Option1_Click()
n = 10
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Option2_Click()
n = 100
End Sub
Private Sub Option3_Click()
n = 1000
End Sub