Solved

UPPER CASE entry field

Posted on 2002-05-23
17
239 Views
Last Modified: 2010-05-02
Hi

I would like to convert the lower case caracter to upper case in an entry field, as they are entered.  How should i proceed ?
thanks in advance
0
Comment
Question by:pchaloux
  • 5
  • 4
  • 4
  • +3
17 Comments
 
LVL 5

Expert Comment

by:bob_online
ID: 7029879
in the keydown event

KeyCode = Asc(Ucase(Chr$(KeyCode)))

This converts the keycode to a character, converts the cuaracter to upper case and converts that back to a keycode integer
0
 
LVL 5

Expert Comment

by:bob_online
ID: 7029882
I'm sorry, that was almost right:  do this in the KeyPress event instead:

KeyAscii = Asc(UCase(Chr$(KeyAscii)))
0
 
LVL 6

Expert Comment

by:holli
ID: 7029885
You can use the following Code:

Private Sub TextboxName_KeyPress(KeyAscii As Integer)
    If KeyAscii >= 97 And KeyAscii <= 122 Then KeyAscii = KeyAscii - 32
End Sub

Alter "TextboxName" to the name of the textbox in your project.


holli
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7029939
yes, but if you cut and copy lower case text then the above code will not work... try this instead:

Private Sub Text1_Change()
    Text1.Text = UCase(Text1.Text)
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7029992
This example not only shows how to do what you want but a bunch of others usefull stuf:
http://www.mvps.org/vbnet/code/textapi/txstyles.htm
0
 

Author Comment

by:pchaloux
ID: 7030266
Private Sub Text1_Change()
   Text1.Text = UCase(Text1.Text)
End Sub

That way, my text is spell backward ...

I'm not using VBNet
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
ID: 7030287
how bout this:
Private Sub Text1_Change()
    Dim ix As Integer
    ix = Text1.SelStart
    Text1.Text = UCase(Text1.Text)
    Text1.SelStart = ix
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7030347
Optionally,
Private Sub Text1_LostFocus()
With Text1
    .Text = UCase$(.Text)
End With
End Sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:pchaloux
ID: 7030369
ok, that should do it.
Thank you, guys
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7030372
'From www.mvps.org/vbnet

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

Private Declare Function SendMessage Lib "user32" _
   Alias "SendMessageA" _
  (ByVal hwnd As Long, _
   ByVal wMsg As Long, _
   ByVal wParam As Long, _
   lParam As Any) As Long
     


Private Sub Form_Load()
Const GWL_STYLE As Long = (-16)
Const ES_UPPERCASE As Long = &H8&
Dim defstyle As Long

defstyle = GetWindowLong(Text1.hwnd, GWL_STYLE)
   
Call SetWindowLong(Text1.hwnd, GWL_STYLE, _
                                  defstyle Or ES_UPPERCASE)
     
End Sub
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7030387
> ok, that should do it.
Thank you, guys

are you gonna accept an answer then?
0
 

Author Comment

by:pchaloux
ID: 7030394
Sorry ,
I thought I did, but I forgot to grade it.
So there you go !
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7030410
thanks!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7030421
Glad you "won" Bobbit31, but strange choice to me.
Cheers
0
 

Author Comment

by:pchaloux
ID: 7030439
Dear Richie_Simonetti,

I hope that your feelings aren't hurt.
I'm sure that your answers were very good, but I think that 30 lines of code to change characters to upper case is a bit too much, this time.

Please, don't answer to this message.  
I gave my grades.  
It's final and without any appeal.
Let's get on with our lives.

ok, bye
0
 
LVL 2

Expert Comment

by:ventond
ID: 7030452
You could also use the Masked Edit Control, in which case you won't have to write any code. Just set a mask.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7030456
Nobody tries to appeal, you can keep your grades where they are.
I was not talking regarding only my comment. Sorry if it appears so.

Have a nice day.
Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now