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.

ASP

Avatar of undefined
Last Comment
R_Harrison

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
funwithdotnet

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Richard Korts

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

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().
R_Harrison

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

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes