Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using For Each to suppress blank lines

Status
Not open for further replies.

CarleyAnn

Programmer
Oct 5, 2006
5
0
0
US
I have a list of fields from an online form that I want to display in the body of an e:mail. I only want fields with data to be there. How can I use vbscripts For Each to add the line to the body variable only if there is data in the field? See list below of current body of which I'd like to suppress blank lines:
Code:
body = "An entry for " & txtDoctorName  & " has been submitted by " & auth_user & " in " & deptx 
& " on " & datex & vbcrlf & vbcrlf _
& "Physician Name: " & namex & vbcrlf _
& "Title: " & titlex & vbcrlf _
& "UPIN: " & upinx & vbcrlf _
& "SSN: " & ssnx & vbcrlf _
& "Number: " & numberx

Thanks! [ponytails2]
 
My best quick guess is to write a "if" statement for each element. I mean something kinda like:

Code:
If datex <> "" or not isnull(datex) then
& " on " & datex & vbcrlf & vbcrlf _
End If

As for using them in a for each, I would say dump all of the items into an array and then use the for each with that. For generic example, I would:

Code:
For Each object in Array1
If object <> "" Then
Do this
Else
Do That
End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top