⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module_commonprocdure.bas

📁 不错的药房管理系统
💻 BAS
字号:
Attribute VB_Name = "Module_CommonProcdure"
Option Explicit

Public Enum InputType
    OnlyInteger = 0
    OnlySingle = 1
    OnlyLetter = 2
End Enum

'限制输入类型
Public Function InputControl(txtBox As Control, KeyCode As Integer, InputTypeIndex As InputType, Optional MaxLength As Integer = 10) As Boolean
    If Len(txtBox) >= MaxLength And KeyCode <> vbKeyBack And KeyCode <> vbKeyReturn Then
        KeyCode = 0
        Exit Function
    End If
    
    Select Case InputTypeIndex
        Case OnlyInteger
            If KeyCode >= 48 And KeyCode <= 57 Or KeyCode = vbKeyBack Or KeyCode = vbKeyReturn Then
                
            Else
                KeyCode = 0
            End If
         Case OnlySingle
            If KeyCode >= 48 And KeyCode <= 57 Or KeyCode = vbKeyBack Or KeyCode = 46 Or KeyCode = vbKeyReturn Then
                
            Else
                KeyCode = 0
            End If
    End Select
End Function

'使文本框得到焦点并全选其中内容
Public Sub SelectTextBoxAll(txtBox As TextBox)
    txtBox.SetFocus
    txtBox.SelStart = 0
    txtBox.SelLength = Len(txtBox)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -