help on vbProper case Curtis's idea

R

riccifs

Hi Curtis,
recently I was looking for a way to change the text in a textbox to
proper case.
I finally decided to use your idea, because I think it is a very
clever way to approach this question.

But I would like to ask you one more question:
Is it possible to enhance this code so that the user can even chose
between upper and lower case?
I mean, if you press tab the text change to proper, as it do now, but
if you press "shift + tab" it becomes upper case, for example! using
another key combination, alt + tab, it change again in lower case...

I am not good with VBA code and I don't known how to start.... could
you help me?
At moment the only modifications I successfully made to your code are:

'**********************************************************************************************************
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyTab Then
Screen.ActiveControl.Text = StrConv(Screen.ActiveControl.Text,
3)
Screen.ActiveControl.Text = Trim(Screen.ActiveControl.Text)
Do Until InStr(Screen.ActiveControl.Text, " ") = 0
Screen.ActiveControl.Text =
Replace(Screen.ActiveControl.Text, " ", " ")
Loop
Else
End If
End Sub
------------------------------------------------------------------------------------------------------------------------------------
Private Sub Form_Load()
Me.KeyPreview = True
End Sub
'**********************************************************************************************************
In this way the text, after the tab press, has no extra spaces between
the words, and no extra spaces at the end or/and beginning.

I hope you will read this e-mail and you will give to me an answer!
thanks a lot,
Stefano.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top