Results 1 to 7 of 7

Thread: [RESOLVED] TextBox is printing backwards on form

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    10

    Resolved [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

  2. #2

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    10

    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!

  3. #3
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,391

    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.

  4. #4
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,468

    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    10

    Re: [RESOLVED] TextBox is printing backwards on form

    Quote Originally Posted by jdc2000 View Post
    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.

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    10

    Re: [RESOLVED] TextBox is printing backwards on form

    Quote Originally Posted by couttsj View Post
    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

  7. #7
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: [RESOLVED] TextBox is printing backwards on form

    Quote Originally Posted by Greyling View Post
    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
  •  



Click Here to Expand Forum to Full Width