Results 1 to 7 of 7

Thread: [RESOLVED] text1.text help

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Resolved [RESOLVED] text1.text help

    multi line textbox

    i wish to add <br> front of all text

    Private Sub Text21_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then ' The ENTER key.
    Text21.Text = "<br>"

    End If
    End Sub
    demo

    once upon a time (i hit enter hey here ) <br> there was a tiger i love it alot (i hit enter hey here ) <br> that night was so good

    output results
    once upon a time <br> there was a tiger i love it alot <br> that night was so good


    how do i do that i wish to add <br> front of current strings when enter key is hit

  2. #2

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: text1.text help

    If KeyAscii = 13 Then ' The ENTER key.
    Text21.Text = Text21.Text & "<br>"

    End If


    when i do this the textbox leaves emty room on top and starts all them in new line dam

  3. #3
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text1.text help

    Text21 = Text21.Text & <br>

    ???

  4. #4
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: text1.text help

    Code:
    Private Sub Text21_KeyPress(KeyAscii As Integer)
      If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
        Text21.Text = Text21.Text & " <br> "
        Text21.SelStart = Len(Text21.Text)
      End If
    End Sub

  5. #5

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: text1.text help

    Quote Originally Posted by Max187Boucher View Post
    Text21 = Text21.Text & <br>

    ???
    i need to do something like this without the keypress event , but keypress event will help me allot when am typing large text instead of click the button

    when i use keypress textbox leaves emty line on top this is another press

    Text21 = Text21.Text & <br> works but thinking what other way i can add this when enter key is pressed so that the textbox dont leave emty line on top

  6. #6
    Lively Member kivisoft@'s Avatar
    Join Date
    Jul 2011
    Location
    Iran
    Posts
    96

    Re: text1.text help

    First of all you can't use KeyPress while the focus is on TextBox! use a key combination like ALT + ENTER

    Second: TEXT21.TEXT = "<br>" & TEXT21.TEXT & "<br>"

  7. #7

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: text1.text help

    Quote Originally Posted by Max187Boucher View Post
    Code:
    Private Sub Text21_KeyPress(KeyAscii As Integer)
      If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
        Text21.Text = Text21.Text & " <br> "
        Text21.SelStart = Len(Text21.Text)
      End If
    End Sub

    great thanks allot

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