Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Tue, 18 Oct 2005 19:09:36 GMT,    group: microsoft.public.inetsdk.programming.scripting.vbscript        back       


Converting a text string that is numeric to an integer ??   
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
date: Tue, 18 Oct 2005 19:09:36 GMT   author:   GLENN LI MEADOWS

Re: Converting a text string that is numeric to an integer ??   
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)
date: 18 Oct 2005 21:15:24 GMT   author:   Evertjan.

Re: Converting a text string that is numeric to an integer ??   
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)
--
date: Wed, 26 Oct 2005 20:51:31 GMT   author:   (Reventlov (see signature))

Re: Converting a text string that is numeric to an integer ??   
Function CheckNumber(str1)
    dblResult = 0
    If IsNumeric(str1) Then
        dblResult = str1
    End If
    dblResult = CDbl(dblResult )
End Function

-- 
dlbjr
Pleading sagacious indoctrination!
date: Wed, 26 Oct 2005 21:49:52 -0500   author:   dlbjr

oops - need to wake up   
Function CheckNumber(str1)
    dblResult = 0
    If IsNumeric(str1) Then
        dblResult = str1
    End If
    CheckNumber = CDbl(dblResult )
End Function


-- 
dlbjr
Pleading sagacious indoctrination!
date: Wed, 26 Oct 2005 21:54:16 -0500   author:   dlbjr

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us