Solved

ASP/javascript in ASP/VBscript

Posted on 2014-02-03
10
580 Views
Last Modified: 2014-02-17
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
0
Comment
Question by:amucinobluedot
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 39830330
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
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 39830340
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
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39830349
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
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39832031
' 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

0
 

Author Comment

by:amucinobluedot
ID: 39854814
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
0
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39854823
this will do exactly as above:

<%
if Qnrview("ParamValue") = "1" then
      Response.Write "HELLO"
elseif Qnrview("ParamValue") = "0" then
      Response.Write "HELLO1"
end if
%>

or you could do:

<%if Qnrview("ParamValue") = "1" then %>
HELLO
<%elseif Qnrview("ParamValue") = "0" then%>
HELLO1
<%end if%>
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 39854824
just curious, did none of the solutions already posted meet your needs?
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 39861803
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.
0
 

Author Comment

by:amucinobluedot
ID: 39862099
Sorry .. I have been out all day. I will test this tomorrow morning
0
 

Author Closing Comment

by:amucinobluedot
ID: 39864826
Perfect, thanks !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question