在VB 语句中 x = Val(Text1.Text) Val Dim y As IntegerPrivate Sub Command1_Click()Text2.Text = yEnd SubPrivate Sub Text1_Change()x = Val(Text1.Text)If x < 0 Or x > 100 ThenText1.Text = ""Text1.SetFocusLabel1.Caption = "请重新输入"ElseLabel1.Ca
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 01:31:20
在VB 语句中 x = Val(Text1.Text) Val Dim y As IntegerPrivate Sub Command1_Click()Text2.Text = yEnd SubPrivate Sub Text1_Change()x = Val(Text1.Text)If x < 0 Or x > 100 ThenText1.Text = ""Text1.SetFocusLabel1.Caption = "请重新输入"ElseLabel1.Ca
在VB 语句中 x = Val(Text1.Text) Val
Dim y As Integer
Private Sub Command1_Click()
Text2.Text = y
End Sub
Private Sub Text1_Change()
x = Val(Text1.Text)
If x < 0 Or x > 100 Then
Text1.Text = ""
Text1.SetFocus
Label1.Caption = "请重新输入"
Else
Label1.Caption = "输入正确"
y = x
End If
End Sub
Val 还有 Else
在VB 语句中 x = Val(Text1.Text) Val Dim y As IntegerPrivate Sub Command1_Click()Text2.Text = yEnd SubPrivate Sub Text1_Change()x = Val(Text1.Text)If x < 0 Or x > 100 ThenText1.Text = ""Text1.SetFocusLabel1.Caption = "请重新输入"ElseLabel1.Ca
'Val函数是将数值型字符串转换为数值型变量,一般用来赋值.
'你上面的语句在TEXT1的内容为空或不是数值时就会出错,最好加上数值检测函数:ISNUMERIC ,如下:
Private Sub Text1_Change()
IF ISNUMERIC(TEXT1.TEXT)=FALSE THEN
MSGBOX "请输入数值!",vbExclamation,"提示"
Exit Sub
ENDIF
x = Val(Text1.Text)
'...