prevent text in TextBox from running off...-VBForums
Results 1 to 3 of 3

Thread: prevent text in TextBox from running off...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    MN
    Posts
    362

    prevent text in TextBox from running off...

    I have code to 'grow' a textbox when the text reaches a certain length. Kinda works, but when user is inputting text, the text length eventually catches up with the TextBox length. Then, the beginning text will disappear to the left.

    Code:
    Private Sub Text1_Change()
    If Len(Text1.Text) > 15 Then
        FitTextBoxContents Text1
    End If
    End Sub
    Private Sub FitTextBoxContents(ByVal ctrlText As TextBox)
        ctrlText.Width = TextWidth(ctrlText.Text) + 400
    End Sub
    Is there a way to prevent text from moving off of the left side of TextBox?

    BTW.. I'm using a multiline TextBox.

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    3,145

    Re: prevent text in TextBox from running off...

    It seems to be working rather perfectly for me. Do you have your form and TextBox set to the same font (especially size)? Don't forget that TextWidth is using the form as its reference, not the textbox.

    EDIT1: Also, a screenshot would be helpful to understand what you're talking about.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    MN
    Posts
    362

    Re: prevent text in TextBox from running off...

    Ahh yes... setting the Form to same font as TextBox worked.......

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.