在VB中如何进行程序的数据输入有效性验证?
特别是对日期的有效性验证该怎么做呢?谢谢! 问题点数:20、回复次数:4Top
1 楼koes(???)回复于 2002-09-02 09:09:37 得分 0
isdate()可以判断的Top
2 楼zhengxh()回复于 2002-09-02 09:21:58 得分 0
那如何判断输入的是数字还是字母呢?
比如我要求输入单价,那文本框就只能输入数字以及小数点,那又该如何判断呢?Top
3 楼gundam_king(东方不败)回复于 2002-09-02 09:28:08 得分 15
给你个函数
Public Function ValiText(KeyIn As Integer, ValidateString As String, Editable As Boolean) As Integer '密码设置
Dim ValidateList As String
Dim KeyOut As Integer
If Editable = True Then
ValidateList = UCase(ValidateString) & Chr(8)
Else
ValidateList = UCase(ValidateString)
End If
If InStr(1, ValidateList, UCase(Chr(KeyIn)), 1) > 0 Then
KeyOut = KeyIn
Else
KeyOut = 0
Beep
End If
ValiText = KeyOut
End Function
然后再text的keypress事件中
KeyAscii = ValiText(KeyAscii, "0123456789.", True)
其中上面的式子中" "可以填入你限制的字符等
此函数通用。这里就只能是数字和小数点Top
4 楼activeL(activeL)回复于 2002-09-02 09:35:47 得分 5
if text1.text<>"" then
if not isnumeric(txt1.text) then
msgbox "请输入数值型数据!",48,"提示"
txet1.setfocus
endif
endif
Top




