Consulting

Results 1 to 3 of 3

Thread: TextBox Editor

  1. #1
    VBAX Regular
    Joined
    Jan 2013
    Location
    House
    Posts
    13
    Location

    TextBox Editor

    Hi

    Create a Multiline TextBox in Userform

    It is possible to insert a row in the text reposition the cursor in the text

    I'm using the following code:
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
      If KeyCode = 13 Then
        Pos = TextBox1.SelStart
        TextBox1.Text = Left(TextBox1.Text, TextBox1.SelStart) & Chr(10) & Mid(TextBox1.Text, TextBox1.SelStart, Len(TextBox1) - TextBox1.SelStart + 1)
        TextBox1.SelStart = Pos
      End If
    End Sub
    Thanks in advance

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    In the VB Editor (VBE), press F4 to show the Properties editor. Click on the TextBox to show its properties and set the EnterKeyBehavior to True. No code needed.

    In the VBE and any of its windows, you can place the cursor in or next to a word and press F1 for help on that item.

    Pressing F2 will bring up the Object Browser with can give you deeper information about things. In the OB, pressing F7 will return to the VBE
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Jan 2013
    Location
    House
    Posts
    13
    Location
    Hi

    Thank you for the information, it is perfect.

Posting Permissions

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