给你个函数
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)
其中上面的式子中" "可以填入你限制的字符等
此函数通用。这里就只能是数字和小数点
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)
其中上面的式子中" "可以填入你限制的字符等
此函数通用。这里就只能是数字和小数点
解决方案 »
- VB GDI 图片透明,叠加
- 我在焦急地等待中啊!各位快来帮忙啊!
- 关于DLL内函数值返回的问题(VB)
- 怎样在任务管理器不显示你的应用程序
- vb编程的难题,求各位大侠帮帮忙
- 请问datagrid怎样用代码加入数据?
- 数据库字段名显示
- ql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=http://127.0.0.1/register.mdb;Persist Security Info=False" 这样写中不?
- 怎么在VB中调用VC写的DLL时候说找不到该DLL?(
- 如何通过Text_Change()事件,修改DataGrid的单元值?
- 乐晕了,散分!
- 如何使程序在支持Unicode的英文系统环境下也可以正常的现实中文?
if not isnumeric(txt1.text) then
msgbox "请输入数值型数据!",48,"提示"
txet1.setfocus
endif
endif