Sankar030999
asked on
text box in uppercase
as i enter the text in a text box, i want it to be displayed in ucase. the ucase fn cannot be used bcos this has to be done as i enter every char. how can this be done. i need the code.
also how can i control capslock from within my app. is this can be done, please let me know how.
also how can i control capslock from within my app. is this can be done, please let me know how.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SendKeys "{CAPSLOCK}", True
if keyAscii >= 97 and KeyAsci <= 122 then
KeyAscii = KeyAscii - 32
endif
This will do one letter at a time...
KeyAscii = KeyAscii - 32
endif
This will do one letter at a time...
Place the following code in a module:
Private Const ES_UPPERCASE = &H8&
Private Const GWL_STYLE = (-16)
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Function SetTextBoxUCase(txtX As TextBox) As Long
On Error Resume Next
Dim lStyle As Long
lStyle = GetWindowLong(txtX.hWnd, GWL_STYLE)
lStyle = lStyle Or ES_UPPERCASE
SetTextBoxUCase = SetWindowLong(txtX.hWnd, GWL_STYLE, lStyle)
End Function
Place this code in the form_load-event:
Private Sub Form_Load()
Call SetTextBoxUCase(Text1)
End Sub
Hope this helps,
Joris
Private Const ES_UPPERCASE = &H8&
Private Const GWL_STYLE = (-16)
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Function SetTextBoxUCase(txtX As TextBox) As Long
On Error Resume Next
Dim lStyle As Long
lStyle = GetWindowLong(txtX.hWnd, GWL_STYLE)
lStyle = lStyle Or ES_UPPERCASE
SetTextBoxUCase = SetWindowLong(txtX.hWnd, GWL_STYLE, lStyle)
End Function
Place this code in the form_load-event:
Private Sub Form_Load()
Call SetTextBoxUCase(Text1)
End Sub
Hope this helps,
Joris
this solutions easier...
use the UCASE function...
e.g.
-------------------------- --
In General Declarations Put:
-------------------------- --
dim text$ as string
-------------------------- ---------- ---
on the text1_keypress event put in this code:
-------------------------- ---------- ---
text$ = text1.text
text1.text = UCASE(text$)
-------------------------- ---------- ----
(assuming your textbox is named text1)
hope this helps...
(UCASE is a standard VB function so it requires no modules or extra code than what you see above)
use the UCASE function...
e.g.
--------------------------
In General Declarations Put:
--------------------------
dim text$ as string
--------------------------
on the text1_keypress event put in this code:
--------------------------
text$ = text1.text
text1.text = UCASE(text$)
--------------------------
(assuming your textbox is named text1)
hope this helps...
(UCASE is a standard VB function so it requires no modules or extra code than what you see above)
ASKER
i want to accept deighton's answer. how can i do it? deighton's is very simple and satisfies my reqirements.
thanks
thanks
For a cut I'll help you out... ;)
kidding
Un I think there is an option accept as answer... just click on that - I've done it before but that doesn't really help does it.
kidding
Un I think there is an option accept as answer... just click on that - I've done it before but that doesn't really help does it.
ASKER
the option "accept comment as answer" was there few days ago. but i guess the site has removed those options now. it isnt there in all the q's
Sankar
Sankar
jzwaenepoel changed the proposed answer to a comment