Click to See Complete Forum and Search --> : If/Then Contains string


platnm0705
12-19-2006, 12:19 PM
I am trying to display a field only if a string contians a certain character, for example (I know the code is wrong, just an example):

IF str1 CONTAINS "this character"
THEN result = "it works"
ELSE result = "not working"

In my real case I need to search a string for an asterisk (*) and only show the string if it contains the asterisk:

IF RS("notes") CONTAINS "*" THEN
response.write " RS("notes") "


Any help would be much appreciated

TheBearMay
12-19-2006, 12:54 PM
Try

If str1.IndexOf("*") > 0 Then

russell
12-19-2006, 01:07 PM
The TheBearMay's suggestion works for JScript. This is how in vbScript
If instr(str1, "*") Then

TheBearMay
12-19-2006, 01:12 PM
The TheBearMay's suggestion works for JScript. This is how in vbScript
If instr(str1, "*") ThenI was thinking VB.Net also contained an IndexOf() function, but since we're in the ASP and not the ASP.Net Forum.... :cool:

platnm0705
12-19-2006, 03:30 PM
Russell,
It works perfectly! Thanks much for the fast reply

My code (if you care):

If instr(RS("notes"), "*") Then
response.write "<table>"
response.write " RS("notes") "
response.write "</table>"
else
end if


-Adam