Copy 1st row only from textbox to email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rlloyd85
    New Member
    • Sep 2009
    • 1

    #1

    Copy 1st row only from textbox to email

    Hi,

    I'm very new to VB... I have a textbox on my form called Unit_2_Defects. I want to copy ONLY the first row of data into an email.

    Example:
    ----------------------------------------------------------
    The defects on this unit are x y and z
    More specifically the defects are related to the engine status and loading problems of the JTY panel.
    -----------------------------------------------------------
    I would like to just copy the first line "The defects on this unit are x y and z" into the email. The line below it I want still in the textbox but not to be copied to the email.

    The code I am using right now:

    strBody = strBody & "2)" & Unit_2 & " is " & Unit_2_Status & " for: " & Left(Unit_2_Def ects, 84) & Chr(13)

    I thought if I just had it count the first 84 characters (which is how long the textbox is) it would only display them, however if the row is short ie only 20 characters, it takes the next line which is what I don't want.

    Can anyone help?
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    dear,

    will this help?

    look for the first Linefeed-Carriagereturn (vbcrlf)
    Like this:
    form with 2 textboxes= text1 and text2
    Text1 MultiLine must be= True
    and 1 command= Command1

    =============== =============== ======
    Private Sub Command1_Click( )
    Text2 = Left(Text1.Text , InStr(Text1.Tex t, vbCrLf) - 1)
    End Sub
    =============== =============== ======

    Comment

    Working...