ctltextbox.ctl
来自「图书管理系统需求规格说明书.doc」· CTL 代码 · 共 109 行
CTL
109 行
VERSION 5.00
Begin VB.UserControl ctlTextBox
ClientHeight = 1290
ClientLeft = 0
ClientTop = 0
ClientWidth = 3810
ScaleHeight = 1290
ScaleWidth = 3810
ToolboxBitmap = "ctlTextBox.ctx":0000
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 0
TabIndex = 0
Top = 0
Width = 1935
End
End
Attribute VB_Name = "ctlTextBox"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim charAccept As Integer
Public Property Get charType() As Integer
charType = charAccept
End Property
Public Property Let charType(ByVal vNewVal As Integer)
charAccept = vNewVal
End Property
Private Sub usercontrol_readproperties(propbag As PropertyBag)
charType = propbag.ReadProperty("charType", 0)
End Sub
Private Sub usercontrol_writeproperties(propbag As PropertyBag)
propbag.WriteProperty "charType", charAccept, 0
End Sub
Private Sub Text1_GotFocus() '获得焦点效果
Text1.BackColor = vbYellow
Text1.ForeColor = vbBlue
End Sub
Private Sub Text1_LostFocus() '失去焦点后效果
Text1.BackColor = vbWhite
Text1.ForeColor = vbBlack
End Sub
'确认用户输入的数据
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyBack Then
Exit Sub
End If
Select Case charAccept
Case 0
Exit Sub
Case 1 '只能写数字
If (KeyAscii >= 48 And KeyAscii <= 57) Then
Exit Sub
Else
KeyAscii = 0
Beep
MsgBox "输入数据类型错误", vbExclamation, "数据输入错误!"
End If
Case 2 '只能字符
If (KeyAscii >= 65 And KeyAscii <= 90) Then
Exit Sub
ElseIf (KeyAscii >= 97 And KeyAscii <= 122) Then
Exit Sub
Else
KeyAscii = 0
Beep
MsgBox "输入数据类型错误", vbExclamation, "数据输入错误"
End If
End Select
End Sub
Private Sub UserControl_Resize()
Text1.Height = UserControl.ScaleHeight
Text1.Width = UserControl.ScaleWidth
End Sub
Public Property Get Text() As String
Text = Text1.Text
End Property
Public Property Let Text(ByVal New_Text As String)
Text1.Text() = New_Text
PropertyChanged "Text"
End Property
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?