Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERT JSCRIPT TO ASP

Status
Not open for further replies.

gsc123

Programmer
Jan 24, 2008
197
How would I convert this statement to asp?

return ((num >= 0)&&(num < 10))?"0"+num:num+"";
 
ASP is a technology, not a language. I use JScript for my ASP programming, so the statement you have would work fine if you have <% @language="jscript" %> at the top of the page.

I suspect you just want that statement translated to VBScript, which would be:
Code:
If (num >=0 And num < 10) Then
  [b][red]functionname[/red][/b] = "0" & num
Else
  [b][red]functionname[/red][/b] = num
End If

You would use the name of the function where I wrote [red]functionname[/red].

Lee
 
What Lee said would work, but if you want to write it in VBScript, you can use the following inline if statement:

Code:
function iif(c,t,f)
	if c then iif = t else iif = f
end function

Where
c = condition
t = return value if true
f = return value if false

Your code would then be

Code:
<%
	num  = 5
	num = iif((num >=0 and num <10), "0" & num, num)
	response.write num
%>


--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top