VB作业之比较三个数的大小

来源:互联网 发布:快穿之那串数据有毒 编辑:程序博客网 时间:2024/05/17 07:38

下面是我编写的程序代码:

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 maxEnd Sub
接着编写“清除”事件的程序:
Private Sub Command2_Click()   Me.Cls   Text1.Text = ""   Text2.Text = ""   Text3.Text = ""End SubPrivate 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 IfEnd Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)   If KeyAscii = 13 Then      Text3.SetFocus      End IfEnd Sub     心得体会:这次作业相比上次作业只是增加了一个个数,但难度似乎增加的很大,摸索出这一类程序的规律,程序就很容易编写了;同样这次用到了“SetFocus”使程序更完美,用起来更方便


 

原创粉丝点击