Results 1 to 2 of 2

Thread: lines of a textbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    11

    lines of a textbox

    how does one specify which line of a text box they want to add to?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Well you cant really specify which line.
    You could however do as in the example below...

    Add two textboxes : Text1 and Text2.
    Set their MultiLine Properties to True.

    Code:
    Option Explicit
    Private tempArray() As String
    
    Private Sub Form_Load()
        
        Text1.Text = ""
        Text2.Text = ""
        
        Me.Show
        Text1.Text = "This is the first line" & vbCrLf & "This is the second line" & vbCrLf & "This is the third line"
        tempArray() = Split(Text1.Text, vbCrLf)
        
        'Each line of text is now stored in an array :
        'tempArray(0) == "This is the first line"
        'tempArray(1) == "This is the second line"
        'tempArray(2) == "This is the third line"
        
        Dim tempStr As String
        tempStr = InputBox("Which line would you like to add ?" & vbCrLf & vbCrLf & "1  ,  2  or  3")
        If (tempStr = "1") Or (tempStr = "2") Or (tempStr = "3") Then
            Text2.Text = tempArray(tempStr - 1)
        End If
        
    End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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