Private Sub Command1_Click()
For a = 1 To Val(Text1)
For b = 1 To Val(Text2)
If Val(Text1) = a + b And Val(Text2) = 2 * a + 4 * b Then
Text3 = a: Text4 = b
End If
Next
Next
End Sub
Private Sub Text1_LostFocus()
If IsNumeric(Val(Text1)) <> True Then
MsgBox "输入的不是数字", vbOKOnly, "错误"
Text1.SetFocus
Text1 = ""
End If
If Val(Text1) <= 0 And Val(Text1) <> Int(Val(Text1)) Then
MsgBox "请输入正整数", vbOKOnly, "错误"
Text1 = ""
Text1.SetFocus
End If
End Sub
Private Sub Text2_LostFocus()
If Val(Text2) Mod 2 <> 0 Then
MsgBox "输入的不是偶数", vbOKOnly, "错误"
Text2 = ""
Text2.SetFocus
End If
End Sub
For a = 1 To Val(Text1)
For b = 1 To Val(Text2)
If Val(Text1) = a + b And Val(Text2) = 2 * a + 4 * b Then
Text3 = a: Text4 = b
End If
Next
Next
End Sub
Private Sub Text1_LostFocus()
If IsNumeric(Val(Text1)) <> True Then
MsgBox "输入的不是数字", vbOKOnly, "错误"
Text1.SetFocus
Text1 = ""
End If
If Val(Text1) <= 0 And Val(Text1) <> Int(Val(Text1)) Then
MsgBox "请输入正整数", vbOKOnly, "错误"
Text1 = ""
Text1.SetFocus
End If
End Sub
Private Sub Text2_LostFocus()
If Val(Text2) Mod 2 <> 0 Then
MsgBox "输入的不是偶数", vbOKOnly, "错误"
Text2 = ""
Text2.SetFocus
End If
End Sub