checknummodule.bas
来自「便利店管理系统 VB+ACCESS 附上数据库和源码」· BAS 代码 · 共 65 行
BAS
65 行
Attribute VB_Name = "checkNumModule"
Option Explicit
Public Function CheckPositiveInt(ByVal KeyAscii As Integer) As Integer '正整数 0~9,BS
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
CheckPositiveInt = KeyAscii
Else
CheckPositiveInt = 0
Beep
End If
End Function
Public Function CheckInt(ByVal KeyAscii As Integer, ByVal TextValue As String) As Integer '整数 0~9, -, BS
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then '整数 0~9, BS
CheckInt = KeyAscii
ElseIf KeyAscii = 45 Then 'And Trim$(TextValue & "") = "" Then '-在第一个位
CheckInt = KeyAscii
Else
CheckInt = 0
Beep
End If
End Function
Public Function CheckDec(ByVal KeyAscii As Integer, ByVal TextValue As String) As Integer '小数 0~9, -, ., BS
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 8 Then
CheckDec = KeyAscii
ElseIf KeyAscii = 45 Then 'And Trim$(TextValue & "") = "" Then '-在第一个位
CheckDec = KeyAscii
ElseIf KeyAscii = 46 And InStr(Trim$(TextValue & ""), ".") = 0 Then '.只出现一次
CheckDec = KeyAscii
Else
CheckDec = 0
Beep
End If
End Function
Public Function CheckDate(ByVal KeyAscii As Integer) As Integer '日期 0~9, -, /, BS
If KeyAscii >= 48 And KeyAscii <= 57 Or KeyAscii = 45 Or KeyAscii = 47 Or KeyAscii = 8 Then
CheckDate = KeyAscii
Else
CheckDate = 0
Beep
End If
End Function
Public Function CheckOperator(ByVal KeyAscii As Integer, ByVal TextValue As String) As Integer '+, -, *, /, ,.不允许操作符出现两次
If (KeyAscii = 43 Or KeyAscii = 45 Or KeyAscii = 42 Or KeyAscii = 47 Or KeyAscii = 46) And InStr(Trim$(TextValue & ""), Chr(KeyAscii)) > 0 Then
CheckOperator = 0
Beep
Else
CheckOperator = KeyAscii
End If
End Function
Public Function toUpperCase(ByVal KeyAscii As Integer) '转化为大写
If KeyAscii >= 97 And KeyAscii <= 122 Then
toUpperCase = KeyAscii - 32
Else
toUpperCase = KeyAscii
End If
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?