Home All Groups Group Topic Archive Search About

how can i detect multiplt VBNewLine's in a row

Author
5 Oct 2006 12:31 PM
SLH
if i have a text area on a page that i want to validate, and i dont want
there to ever be 2 "enter"s in a row, how can i check for this?
ive been playing with something like:

If InStr(string, "vbnewline&vbnewline") <> 0

but i cant get that to work no matter what i do with the quotes etc. but
thats the general idea of what i want to do.
any ideas?

Author
5 Oct 2006 12:38 PM
Bob Barrows [MVP]
SLH wrote:
> if i have a text area on a page that i want to validate, and i dont
> want there to ever be 2 "enter"s in a row, how can i check for this?
> ive been playing with something like:
>
> If InStr(string, "vbnewline&vbnewline") <> 0
>
> but i cant get that to work no matter what i do with the quotes etc.
> but thats the general idea of what i want to do.
> any ideas?

vbCrLf & vbCrLf
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Are all your drivers up to date? click for free checkup

Author
5 Oct 2006 12:54 PM
SLH
thank you ill try that now. question, what is the actual difference between
vbNewLine and vbCrLf?
i ask because i do some other things on various pages using vbNewLine and im
wondering if there is good reason to change it to vbCrLf

thanks



Show quoteHide quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OpvDwsH6GHA.4644@TK2MSFTNGP04.phx.gbl...
> SLH wrote:
>> if i have a text area on a page that i want to validate, and i dont
>> want there to ever be 2 "enter"s in a row, how can i check for this?
>> ive been playing with something like:
>>
>> If InStr(string, "vbnewline&vbnewline") <> 0
>>
>> but i cant get that to work no matter what i do with the quotes etc.
>> but thats the general idea of what i want to do.
>> any ideas?
>
> vbCrLf & vbCrLf
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Author
5 Oct 2006 1:32 PM
Bob Barrows [MVP]
They are platform/situation-dependent:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp

I posted that suggestion without testing, assuming it would be the
answer. It turns out I was wrong. According to this test:
<%
dim s, i, ar
ar=array(vbNewLine, vbCrLf)
for each s in ar
Response.Write "Next constant:<BR>"
for i = 1 to len(s)
  Response.Write Asc(mid(s,i,1)) & "<BR>"
next
next
%>

The two constants would seem to be equivalent in this situation. So, I
would suggest looping through your string (similar to the above) and
discover what actually is being passed in the form submission for line
break characters.

In fact, based on this test:
<%
if Request.Form.Count>0 then
dim s, i
s=Request.Form("txt")
for i = 1 to len(s)
  Response.Write Asc(mid(s,i,1)) & "<BR>"
next
Response.Write "Instr(s,vbCrLf & vbCrLf): " & Instr(s,vbCrLf & vbCrLf)
& "<BR>"
Response.Write "Instr(s,vbNewLine & vbNewLine): " & Instr(s,vbNewLine &
vbNewLine) & "<BR>"
end if
%>
<HTML>
<BODY>
<FORM action="" method=POST id=form1 name=form1>
<textarea name=txt></textarea>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
</FORM>
</BODY>
</HTML>

Both constants seem to work when I enter a<enter><enter>a in the text
area and submit it.



SLH wrote:
Show quoteHide quote
> thank you ill try that now. question, what is the actual difference
> between vbNewLine and vbCrLf?
> i ask because i do some other things on various pages using vbNewLine
> and im wondering if there is good reason to change it to vbCrLf
>
> thanks
>
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:OpvDwsH6GHA.4644@TK2MSFTNGP04.phx.gbl...
>> SLH wrote:
>>> if i have a text area on a page that i want to validate, and i dont
>>> want there to ever be 2 "enter"s in a row, how can i check for this?
>>> ive been playing with something like:
>>>
>>> If InStr(string, "vbnewline&vbnewline") <> 0
>>>
>>> but i cant get that to work no matter what i do with the quotes etc.
>>> but thats the general idea of what i want to do.
>>> any ideas?
>>
>> vbCrLf & vbCrLf
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Author
5 Oct 2006 1:42 PM
SLH
Show quote Hide quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:uVaT$KI6GHA.1688@TK2MSFTNGP06.phx.gbl...
> They are platform/situation-dependent:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/scriptinga.asp
>
> I posted that suggestion without testing, assuming it would be the
> answer. It turns out I was wrong. According to this test:
> <%
> dim s, i, ar
> ar=array(vbNewLine, vbCrLf)
> for each s in ar
> Response.Write "Next constant:<BR>"
> for i = 1 to len(s)
>  Response.Write Asc(mid(s,i,1)) & "<BR>"
> next
> next
> %>
>
> The two constants would seem to be equivalent in this situation. So, I
> would suggest looping through your string (similar to the above) and
> discover what actually is being passed in the form submission for line
> break characters.
>
> In fact, based on this test:
> <%
> if Request.Form.Count>0 then
> dim s, i
> s=Request.Form("txt")
> for i = 1 to len(s)
>  Response.Write Asc(mid(s,i,1)) & "<BR>"
> next
> Response.Write "Instr(s,vbCrLf & vbCrLf): " & Instr(s,vbCrLf & vbCrLf)
> & "<BR>"
> Response.Write "Instr(s,vbNewLine & vbNewLine): " & Instr(s,vbNewLine &
> vbNewLine) & "<BR>"
> end if
> %>
> <HTML>
> <BODY>
> <FORM action="" method=POST id=form1 name=form1>
> <textarea name=txt></textarea>
> <INPUT type="submit" value="Submit" id=submit1 name=submit1>
> </FORM>
> </BODY>
> </HTML>
>
> Both constants seem to work when I enter a<enter><enter>a in the text
> area and submit it.
>
>
>
> SLH wrote:
>> thank you ill try that now. question, what is the actual difference
>> between vbNewLine and vbCrLf?
>> i ask because i do some other things on various pages using vbNewLine
>> and im wondering if there is good reason to change it to vbCrLf
>>
>> thanks
>>
>>
>>
>> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
>> news:OpvDwsH6GHA.4644@TK2MSFTNGP04.phx.gbl...
>>> SLH wrote:
>>>> if i have a text area on a page that i want to validate, and i dont
>>>> want there to ever be 2 "enter"s in a row, how can i check for this?
>>>> ive been playing with something like:
>>>>
>>>> If InStr(string, "vbnewline&vbnewline") <> 0
>>>>
>>>> but i cant get that to work no matter what i do with the quotes etc.
>>>> but thats the general idea of what i want to do.
>>>> any ideas?
>>>
>>> vbCrLf & vbCrLf
>>> --
>>> Microsoft MVP -- ASP/ASP.NET
>>> Please reply to the newsgroup. The email account listed in my From
>>> header is my spam trap, so I don't check it very often. You will get
>>> a quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



right now im looking for vbCrLf & vbCrLf (2 or more in a row) and replacing
with a single vbCrLf.
i keep looping until theyve all been replaced. this seems to work....
Author
5 Oct 2006 1:51 PM
Bob Barrows [MVP]
SLH wrote:

> right now im looking for vbCrLf & vbCrLf (2 or more in a row) and
> replacing with a single vbCrLf.
> i keep looping until theyve all been replaced. this seems to work....

Something like this?

Do Until Instr(string, vbCrLf & vbCrLf)=0
    string = Replace(string,vbCrLf & vbCrLf,vbCrLf)
Loop

(yeah, I know there's a great regex solution for this, but I'm leaving
that as an exercise ... )



--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Author
5 Oct 2006 1:36 PM
Bob Barrows [MVP]
SLH wrote:
> if i have a text area on a page that i want to validate, and i dont
> want there to ever be 2 "enter"s in a row, how can i check for this?
> ive been playing with something like:
>
> If InStr(string, "vbnewline&vbnewline") <> 0
>
Oh jeez, I just noticed. it should be:

If InStr(string, vbnewline & vbnewline) > 0 then


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Bookmark and Share