[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 888
  • Last Modified:

Type Mismatch calling VBScript function from ASP

I have what is a very simple function that pads a single digit with a leading "0" like.  I am losing my mind trying to figure out WHY I can't get any return but "Type Mismatch".  The code below treats it like a string, but I have tried forcing it to integer with cint and I can't get it to do anything but complain about a type mismatch.

AND I'm WAY behind schedule!  Argggggg - I should have used php.

<HTML><HEAD>
<Script LANGUAGE = "VBScript">
	function LPad(Idx)
		if len(idx) > 1 then
			LPad=idx
		else
			LPad="0" & idx
		end if
	end function
</Script>
</HEAD>
<Body>
<%
sNum=1
response.write LPad(sNum)
%>
</body>
</html>

Open in new window

0
jriggin
Asked:
jriggin
  • 2
1 Solution
 
Ryan ChongCommented:
this instead:
<HTML><HEAD>
<%
        function LPad(Idx)
                if len(idx) > 1 then
                        LPad=idx
                else
                        LPad="0" & idx
                end if
        end function
%>
</HEAD>
<Body>
<%
sNum=1
response.write LPad(sNum)
%>
</body>
</html>

Open in new window

0
 
Ryan ChongCommented:
or if you want do it on client side, try:
<HTML><HEAD>
<Script LANGUAGE = "VBScript">
        function LPad(Idx)
                if len(idx) > 1 then
                        LPad=idx
                else
                        LPad="0" & idx
                end if
        end function
</Script>
</HEAD>
<Body>
<script language="vbscript">
sNum=1
document.write LPad(sNum)
</script>
</body>
</html>

Open in new window

0
 
jrigginAuthor Commented:
Thank you!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now