Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

ASP/javascript in ASP/VBscript

I have this code which works for ASP/Javascript pages

<% if (Qnrview.Fields.Item("ParamValue").Value == (1)) { // script %>
HELLO
<% } // if (Qnrview.Fields.Item("ParamValue").Value == (1)) script %>


I need to aquivalent for ASP/VB Script
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

give this a shot

<%
if Qnrview("ParamValue") = 1 then
response.write "Hello 1"
else
response.write "Hello 2"
end if
%>

Open in new window


Carrzkiss
Also.
Since you are just getting into ASP Classic VB
May I suggest the following Video Lesson's
http://www.youtube.com/playlist?list=PL00AD0C15B4892027


Good Luck
Carrzkiss
if you have other values for ParamValue, I would use a select statement:

<%
dim param: param = Qnrview("ParamValue")

if param = "" or not isNumeric( param ) then
   param = -1
else
   param = CInt( param )
end if

if param > -1 then
   select case param
      case 1: Response.Write "Hello 1"
      case 2: Response.Write "Hello 2"
      default: "Default message if param doesn't equal the other values"
   end select
end if
' trim takes out any space " 1 " becomes "1".
' Cstr converts numeric to a string.  This way you account for blanks.  
if Cstr(trim(Qnrview.Fields.Item("ParamValue").Value))="1" then
    response.write "hello, I am 1"
    else
    response.write "sorry, I am not 1"
end if

' if you want to account for the null values
if not isnull(Qnrview.Fields.Item("ParamValue").Value) then
   if Cstr(trim(Qnrview.Fields.Item("ParamValue").Value))="1" then
       response.write "hello, I am 1"
       else
       response.write "sorry, I am not 1"
   end if
end if

Open in new window

Avatar of Aleks

ASKER

Lets try once more. I have this code in Classic ASP/Javascript and need two lines in ASP/VBScript to replace this code:

<% if (Qnrview.Fields.Item("ParamValue").Value == (1)) { // script %>
HELLO
<% } // if (Qnrview.Fields.Item("ParamValue").Value == (0)) script %>
HELLO1
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

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
just curious, did none of the solutions already posted meet your needs?
The code that I posted above
http:#a39830330
Will do what you want, in VB, just as your code did in JS.
With the least amount of code lines.
Avatar of Aleks

ASKER

Sorry .. I have been out all day. I will test this tomorrow morning
Avatar of Aleks

ASKER

Perfect, thanks !