当前位置:编程学习 > VB >>

请问一个VB问题,开启大写怎么实现?代码?

如图!

补充:我想点击那个后,那个键盘的大写灯亮。或者text1只能输入大写字母,就是屏蔽输入法!
答案:下面的代码测试通过:

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Sub SetKeyState(ByVal Key As Long, ByVal State As Boolean)
Call keybd_event(Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or 0, 0)
Call keybd_event(Key, MapVirtualKey(Key, 0), KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End Sub
Private Property Get CapsLock() As Boolean
CapsLock = GetKeyState(KeyCodeConstants.vbKeyCapital) = 1
End Property
Private Property Let CapsLock(ByVal Value As Boolean)
Call SetKeyState(KeyCodeConstants.vbKeyCapital, Value)
End Property

Private Sub Form_Load()
If CapsLock Then
Check1.Value = 1
End If
End Sub

Private Sub Check1_Click()
CapsLock = Not CapsLock
If Check1.Value = 1 And CapsLock Then
CapsLock = Not CapsLock
End If
End Sub

你的意思是将小写字符转换为大写吗 用UCASE(字符) 出来就是了 LCASE(字符)是小写

上一个:用VB编程 “儿童认识钟表” 约50行
下一个:VB.net代码转换成C#代码,handles如何处理?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,