看看符不符合您要的(BY VB6)
Option Explicit
Private Sub cmdCount_Click()
Dim JetT1 As Boolean, JetT2 As Boolean, JetT3 As Boolean
Dim JetCount As Integer
If t1.Text <> "" Then
JetCount = JetCount + 1
JetT1 = True
End If
If t2.Text <> "" Then
JetCount = JetCount + 1
JetT2 = True
End If
If t3.Text <> "" Then
JetCount = JetCount + 1
JetT3 = True
End If
If JetCount <> 2 Then
MsgBox "Error"
Else
If JetT3 Then
If JetT2 Then
t1.Text = CStr(Val(t3.Text) / Val(t2.Text))
Else
t2.Text = CStr(Val(t3.Text) / Val(t1.Text))
End If
Else
t3.Text = Trim(Str(Val(t1.Text) * Val(t2.Text)))
End If
End If
End Sub
Private Sub t1_KeyPress(KeyAscii As Integer)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
Private Sub t2_KeyPress(KeyAscii As Integer)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
Private Sub t3_KeyPress(KeyAscii As Integer)
If InStr("0123456789", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
End If
End Sub
|