Connecting Tech Pros Worldwide Forums | Help | Site Map

Copy 1st row only from textbox to email

Newbie
 
Join Date: Sep 2009
Posts: 1
#1: Sep 29 '09
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_Defects, 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?

Newbie
 
Join Date: Oct 2009
Posts: 18
#2: Oct 13 '09

re: Copy 1st row only from textbox to email


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.Text, vbCrLf) - 1)
End Sub
====================================
Reply


Similar Visual Basic 4 / 5 / 6 bytes