-
Jan 24th, 2018, 02:40 PM
#1
Thread Starter
New Member
[RESOLVED] TextBox is printing backwards on form
Hello, strange problem here. It was working then 'Something' must have happened to change it.
When I type into all the textboxs on my form, the the text is backwards, in other words if I try to type
'ABC' into the box, the cursor slides left after every stroke resulting in 'CBA' in the box. I have already looked at
the propertys box at the 'RightToLeft' and it is FALSE on all forms so thats not it. I have never seen this happen before.
Any ideas on what I may have done without realizing it to make this happen?
I do have some code in the TextBox_Change() event but it only forces caps on.
Here is the code --- txtTYPE.Text = UCase(txtTYPE.Text) ---
Like I said this WAS working fine, then I noticed it. Not sure what I did to make it change.
Any ideas??
Thanks
-
Jan 24th, 2018, 03:10 PM
#2
Thread Starter
New Member
Re: [RESOLVED] TextBox is printing backwards on form
I found a work around
Text1.SelStart = Len(Text1.Text)
But I still have no idea what would cause the cursor to slide to the first position after each character is typed.
The space bar will move it right as well as arrow keys, but all letters and numbers make the cursor slide to the left.
Wierd!
-
Jan 24th, 2018, 04:07 PM
#3
Re: [RESOLVED] TextBox is printing backwards on form
I am not sure how your "work around" would actually solve the issue.
Does this happen in all VB6 projects, or just the one?
Does it happen in other non-VB6 text boxes in other windows?
I assume that you did not change your regional settings to something that would cause Windows to default to this behavior.
-
Jan 24th, 2018, 04:57 PM
#4
Re: [RESOLVED] TextBox is printing backwards on form
You are replacing the entire contents of the text box with every key stroke and the cursor always ends up at the start. Try using this code instead:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > 96 And KeyAscii < 123 Then KeyAscii = KeyAscii - 32
End Sub
-
Jan 25th, 2018, 03:06 AM
#5
Thread Starter
New Member
Re: [RESOLVED] TextBox is printing backwards on form
Originally Posted by jdc2000
I am not sure how your "work around" would actually solve the issue.
Does this happen in all VB6 projects, or just the one?
Does it happen in other non-VB6 text boxes in other windows?
I assume that you did not change your regional settings to something that would cause Windows to default to this behavior.
It was just that one project.
I did find out a little more info...It appears that if a textbox is in 'Edit Mode' ,(whatever that is) will make the cursor behave that way.
I found that out in a thread someplace.
-
Jan 25th, 2018, 03:09 AM
#6
Thread Starter
New Member
Re: [RESOLVED] TextBox is printing backwards on form
Originally Posted by couttsj
You are replacing the entire contents of the text box with every key stroke and the cursor always ends up at the start. Try using this code instead:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > 96 And KeyAscii < 123 Then KeyAscii = KeyAscii - 32
End Sub
What conditions would make a textbox start doing that??
How can I avoid it in future?
Thnx
-
Jan 25th, 2018, 07:38 AM
#7
Re: [RESOLVED] TextBox is printing backwards on form
Originally Posted by Greyling
What conditions would make a textbox start doing that??
How can I avoid it in future?
Thnx
That was already answered. If you replace the text in the textbox with new text, the cursor is placed at the beginning of the textbox.
Your use of UCase is replacing the text in the textbox with a completely new string so the cursor ends up at the beginning of the text instead of at the end.
The way you avoid it in the future is to not replace the whole string with new text, or manually set the cursor to the end of the string (i.e. your work around) or use code like couttsj provided to change the character to uppercase before it is added to the textbox so you don't replace the text in the textbox itself.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|