?
Solved

text box in uppercase

Posted on 2000-02-08
9
Medium Priority
?
158 Views
Last Modified: 2010-05-02
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.  
0
Comment
Question by:Sankar030999
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 200 total points
ID: 2499710
Private Sub Text2_KeyPress(KeyAscii As Integer)

    KeyAscii = Asc(UCase(Chr(KeyAscii)))

End Sub

0
 
LVL 18

Expert Comment

by:deighton
ID: 2499957
SendKeys "{CAPSLOCK}", True
0
 

Expert Comment

by:woottond
ID: 2500440
if keyAscii >= 97 and KeyAsci <= 122 then
     KeyAscii = KeyAscii - 32
endif

This will do one letter at a time...

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 1

Expert Comment

by:jzwaenepoel
ID: 2500859
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
0
 

Expert Comment

by:stedan_98
ID: 2514053
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)
0
 

Author Comment

by:Sankar030999
ID: 2577280
i want to accept deighton's answer. how can i do it? deighton's is very simple and satisfies my reqirements.
thanks
0
 

Expert Comment

by:woottond
ID: 2577503
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.
0
 

Author Comment

by:Sankar030999
ID: 2578683
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
0
 
LVL 1

Expert Comment

by:jzwaenepoel
ID: 2579641
jzwaenepoel changed the proposed answer to a comment
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question