用VB制作一个加法器

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:39:51
有三个LABEL!!!
每个LABEL对应一个TEXT!!
LABEL1是被加数
LABEL 2 加数
LABEL 3 得数
两个COMMAND
COMMAND 1是计算
COMMAND 2 清除

谢谢谢谢!!

Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
s = a + b
Text3 = s
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
End Sub
Private Sub Form_Load()
Dim a As Integer
Dim b As Integer
Dim s As Integer
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call Command1_Click
KeyAscii = 0
Text3.SetFocus
End If
End Sub
Private Sub Text3_Change()
With Text3

.SelStart = Len(.Text)
.SetFocus
End With
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call Command2_Click
KeyAscii = 0
End If
E