下一页 1 2 3
如何让程序在 Windows 启动时自动执行 Private Sub Text1_GotFocus()
有以下二个方法:
方法1: 直接将快捷方式放到启动群组中。
方法2:
在注册档 HKEY_LOCAL_MACHINE 中找到以下机码:\Software\Microsoft\Windows\CurrentVersion\Run
新增一个字串值,包括二个部份:
1. 名称部份:自己取名,可设定为 AP 名称。
2. 资料部份:则是包含 '全路径档案名称' 及 '执行参数'
例如:
Value Name = Notepad
Value Data = c:\windows\notepad.exe
在 TextBox 中如何限制只能输入数字
参考下列程序:
Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
TextBox 中能不接受某些特定字符(如 '@#$%")
方法有好几种, 以下列举二种:
方法1: 可以使用 IF 或 Select Case 一个个判断, 但如果不接受的字符多时, 较麻烦!
方法2: 将要剔除的字符统统放在一个字串中,只要一个 IF 判断即可 !! 如下:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim sTemplate As String
sTemplate = "!@#$%^&*()_+-=" '用来存放不接受的字符
If InStr(1, sTemplate, Chr(KeyAscii)) > 0 Then
KeyAscii = 0
End If
End Sub
如何让鼠标进入 TextBox 时自动选定 TextBox 中之整串文字
这个自动选定反白整串文字的动作,会使得输入的资料完全取代之前在 TextBox 中的所有字符。
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
End Sub