Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

How to detect blank lines in <textarea>

I have a form the uses <textarea> ... </textarea> to pick up large amounts of test. I proceess the results with an asp script.

How can I detect blank lines in the incoming text? I need to process differently with blank lines in the input form field.

ASKER CERTIFIED SOLUTION
Avatar of funwithdotnet
funwithdotnet

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Korts

ASKER

To funwithdotnet:

So I could do something like this:
str = Request.Form("textArea")
ln = len(str)
for i = 1 to ln
if mid(str,i,1) = Chr(13) or mid(str,i,10) = Chr(10) then
' logic for blank line
else
' regular logic
end if
next

Avatar of funwithdotnet
funwithdotnet

You have to check for a pair of either cr&lf, lf or cr. Seeing a pair of the forementioned denote a 'blank' line. You can't do it with the code you have because you have to find a pir of the chars. Use InStr() to find the position of the first cr/lf character. Then depending on which set of characters is encountered, there will be either 2 or four characters to deal with, beginning with the integer returned by the InStr().
You could always use the replace command to switch the VBCRLF, CR, LF, etc to a more freindly character such as ~, then use your code checking for ~ signs instead?

e.g
str=Replace(Request.Form("textarea"), vbcrlf, "~")
str=Replace(str, chr(10), "~")
str=Replace(str, chr(13), "~")

ln = len(str)
for i = 1 to ln
if mid(str,i,1) = "~" then
' logic for blank line
else
' regular logic
end if
next