Hello, I want to take a string such as "123" and convert it to a number. I first check to see if it is a numeric text string using the IsNumeric ( str) function. If it is, I attempt to use the Val ( ) function but VBScript does not support this function. Is there another way to convert this string to an integer? Thanks in advance glenn
GLENN LI MEADOWS wrote on 18 okt 2005 in microsoft.public.inetsdk.programming.scripting.vbscript: > I want to take a string such as "123" and convert it to a number. I > first check to see > if it is a numeric text string using the IsNumeric ( str) function. > If it is, I attempt to > use the Val ( ) function but VBScript does not support this function. > > Is there another way to convert this string to an integer? Why an integer? More general would be a floating point: <script language=vbs> s = "0005.432100" document.write s & " string" & "<br>" document.write 0 + +s & " unary+ +s" & "<br>" document.write - -s & " unary- -s" & "<br>" document.write 1*s & " multiply 1*s" & "<br>" document.write s-0 & " minus zero s-0" & "<br>" document.write cDbl(s) & " function cdbl(s)" & "<br>" </script> however cInt() and cLng() are available, if a [rounded] integer is required, as are the "old style basic" Int() and Fix(). Perhaps reading the specs would do? -- Evertjan. The Netherlands. (Replace all crosses with dots in my emailaddress)
Il giorno Tue, 18 Oct 2005 19:09:36 GMT, "GLENN LI MEADOWS" ha scritto: >I want to take a string such as "123" and convert it to a number. I first >check to see >if it is a numeric text string using the IsNumeric ( str) function. If it >is, I attempt to >use the Val ( ) function but VBScript does not support this function. Num= "123" * 1 -- Giovanni Cenati (Aosta, Italy) Write to user "Reventlov" and domain at katamail com http://digilander.libero.it/Cenati (VbScript) --
Function CheckNumber(str1) dblResult = 0 If IsNumeric(str1) Then dblResult = str1 End If dblResult = CDbl(dblResult ) End Function -- dlbjr Pleading sagacious indoctrination!
Function CheckNumber(str1) dblResult = 0 If IsNumeric(str1) Then dblResult = str1 End If CheckNumber = CDbl(dblResult ) End Function -- dlbjr Pleading sagacious indoctrination!