已解决问题 - 浏览336次
下一个已解决问题最佳答案 - 由投票者2008-01-14 17:32:16选出
如果规定不大于某一定值,你可以在属性窗口maxlength属性设定
但是如规定了最小值你可以直接编写
例:
Private Sub Command1_Click()
Dim a$, b%, c$
a = Text1.Text
While c <> Text1.Text
b = b + 1
c = Right(a, b)
Wend
If b <= 8 Or b >= 20 Then
Form1.Cls
a = MsgBox("友好提示", vbOKOnly, "输入数据有误,请重新输放!")
If a = vbOKOnly Then Form1.Cls
End If
a = MsgBox("友好提示", vbOKOnly, "数据格式合格,可以进行下步操作!")
If a = vbOKOnly Then Form1.Cls
其他回答(2)
-
可以用控件指定他的文字形式为字母,长度可以用:this.text.length<=20
this.text.length>=8 -
Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 Then
If Len(Text1.Text) < 20 Then
Select Case KeyAscii
Case 97 To 122
Case 65 To 90
Case Else
KeyAscii = 0
End Select
Else
KeyAscii = 0
End If
Else
If Len(Text1.Text) < 9 Then KeyAscii = 0
End If
End Sub



daxiong1232003
۞۩☻♪♫₧













