''运行下面的 Dim X, Y, z As Double Dim flg As IntegerPrivate Sub Form_Load() Text1.Text = "" Text2.Text = "" Text4.Text = "" flg = 0 End SubPrivate Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If flg = 1 Then Exit Sub Dim a As Double a = X / Y Text4.Text = CStr(a)End SubPrivate Sub Text1_LostFocus() If IsNumeric(Text1.Text) Then If Text1.Text > 20 Then X = Val(Text1.Text) flg = 1 Text2.SetFocus Else MsgBox "请输入大于20的数字", 48 Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) Text1.SetFocus Exit Sub End If Else MsgBox "请输入数字", 48 Text1.Text = "" Text1.SetFocus End IfEnd Sub Private Sub Text2_LostFocus() If IsNumeric(Text1.Text) And Text2.Text <> "" And IsNumeric(Text2.Text) Then Y = Val(Text2.Text) Text4.SetFocus flg = 0 Else If flg = 1 Then MsgBox "请输入数字", 48 Text2.Text = "" Text2.SetFocus End If End If End Sub================================================================================ ''''你 的 代码乱七八糟的!Dim x, y, z As Double ...x = Text1.Text '''这里怎么把 STRING 赋值给了 DOUBLE 的变量??还有,不要乱用SetFocus 和KeyPress 事件! 特别是别和 MSGBOX 一起用!你的逻辑太乱了,需要好好练习
Dim X, Y, z As Double
Dim flg As IntegerPrivate Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text4.Text = ""
flg = 0
End SubPrivate Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If flg = 1 Then Exit Sub
Dim a As Double
a = X / Y
Text4.Text = CStr(a)End SubPrivate Sub Text1_LostFocus()
If IsNumeric(Text1.Text) Then
If Text1.Text > 20 Then
X = Val(Text1.Text)
flg = 1
Text2.SetFocus
Else
MsgBox "请输入大于20的数字", 48
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
Exit Sub
End If
Else
MsgBox "请输入数字", 48
Text1.Text = ""
Text1.SetFocus
End IfEnd Sub
Private Sub Text2_LostFocus()
If IsNumeric(Text1.Text) And Text2.Text <> "" And IsNumeric(Text2.Text) Then
Y = Val(Text2.Text)
Text4.SetFocus
flg = 0
Else
If flg = 1 Then
MsgBox "请输入数字", 48
Text2.Text = ""
Text2.SetFocus
End If
End If
End Sub================================================================================
''''你 的 代码乱七八糟的!Dim x, y, z As Double
...x = Text1.Text '''这里怎么把 STRING 赋值给了 DOUBLE 的变量??还有,不要乱用SetFocus 和KeyPress 事件! 特别是别和 MSGBOX 一起用!你的逻辑太乱了,需要好好练习