下面是我编写的程序代码:
Private Sub Command1_Click()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim max As Integer
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
If A > B Then
max = A
Else
max = B
End If
If C > max Then
max = C
End If
Print max
End Sub
接着编写“清除”事件的程序:
Private Sub Command2_Click()
Me.Cls
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.Private Sub Command2_Click()
Me.Cls
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub 心得体会:这次作业相比上次作业只是增加了一个个数,但难度似乎增加的很大,摸索出这一类程序的规律,程序就很容易编写了;同样这次用到了“SetFocus”使程序更完美,用起来更方便