VB的一些项目中常用的通用方法-一般用于验证类

1.VB的一些项目中常用的通用方法:

'  设置校验键盘输入值,数字
Public Function kyd(key As Integer) As Integer
'20060728
Dim mychar
  mychar = "0123456789-" & Chr(8) & Chr(46)

 If InStr(mychar, Chr(key)) = 0 Then
        kyd = 0
       ' MsgBox "只能输入数字"
        Exit Function
  Else
        kyd = key
 End If

End Function

' 设置校验键盘输入值,数字
Public Function knum(key As Integer) As Integer
'20060728
Dim mychar
  mychar = "0123456789." & Chr(8) & Chr(46)

 If InStr(mychar, Chr(key)) = 0 Then
       knum = 0
       
      ' MsgBox "只能输入数字"
      
       Exit Function
  Else
       knum = key
 End If

End Function

' 设置校验键盘输入值,数字
Public Function krq(key As Integer) As Integer
'20060728
Dim mychar
  mychar = "0123456789" & Chr(8) & Chr(46)

 If InStr(mychar, Chr(key)) = 0 Then
       krq = 0
       
      ' MsgBox "只能输入数字"
      
       Exit Function
  Else
       krq = key
 End If

End Function


' 设置校验键盘输入值,数字和字母可以
Public Function knumCHAR(key As Integer) As Integer
'20060728
Dim mychar
  mychar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" & Chr(8) & Chr(46)

 If InStr(mychar, Chr(key)) = 0 Then
       key = 0
       
      ' MsgBox "只能输入数字"
      
       Exit Function
  Else
      ' key = key
 End If

End Function

 

posted @ 2013-11-14 13:43  王春天  阅读(550)  评论(0编辑  收藏  举报
云推荐