Ghost in text box

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Ghost in text box

Post by sal21 »

I digit ABCD in this textbox and insted to have ABCD see image!!!!

code:
Private Sub Text11_Change()
Text11.Text = UCase(Text11.Text)
End Sub

in effect i need to write always in ucase into textbox independent if i use a caps or shift down
Immagine.JPG
You do not have the required permissions to view the files attached to this post.
Last edited by HansV on 22 Oct 2011, 21:29, edited 1 time in total.
Reason: to remove white space from screenshot

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Ghost in text box

Post by HansV »

Try using the After Update event of the text box instead of the Change event:

Code: Select all

Private Sub Text11_AfterUpdate()
    Text11.Text = UCase(Text11.Text)
End Sub
The code will fire when the user moves to a different control.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: Ghost in text box

Post by sal21 »

HansV wrote:Try using the After Update event of the text box instead of the Change event:

Code: Select all

Private Sub Text11_AfterUpdate()
    Text11.Text = UCase(Text11.Text)
End Sub
The code will fire when the user moves to a different control.
i dont see AfterUpdate in the list of textbox this property... see image
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Ghost in text box

Post by HansV »

I always forget you're using VB6.

Have you perhaps set the RightToLeft property of the text box to True?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: Ghost in text box

Post by sal21 »

HansV wrote:I always forget you're using VB6.

Have you perhaps set the RightToLeft property of the text box to True?
i just have see... no is false

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Ghost in text box

Post by HansV »

Thanks for checking. What if you use the KeyPress event instead of the Change event?

Code: Select all

Private Sub Text11_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 97 To 122
            KeyAscii = KeyAscii - 32
    End Select
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Re: Ghost in text box

Post by sal21 »

HansV wrote:Thanks for checking. What if you use the KeyPress event instead of the Change event?

Code: Select all

Private Sub Text11_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
        Case 97 To 122
            KeyAscii = KeyAscii - 32
    End Select
End Sub
You are a genius!
:thankyou: :thankyou: :thankyou: :thankyou: :thankyou: :thankyou: :thankyou: :thankyou: