Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Val() function equivalent in VBScript

6,233 views
Skip to first unread message

srudenko

unread,
May 19, 2004, 3:47:43 PM5/19/04
to
Does VBScript have an equivalent of visual basic Val()
function?
Trying to convert HEX to DEC so using something like this:
txtoutput = Val("&H" & txtInput & "&")

VBScript keeps on saying Type Mismatch Val


Steve, I-Net+
http://www.webzila.com

Viatcheslav V. Vassiliev

unread,
May 19, 2004, 3:59:21 PM5/19/04
to
Just translate it into integer and back to string:

CStr(CInt("&H123F"))

("&" at end is not needed)

or just

CInt("&H123F")

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"srudenko" <srud...@mail.ev1.net> сообщил/сообщила в новостях следующее:
news:40abb978.594.41@news2...

srudenko

unread,
May 19, 2004, 4:11:06 PM5/19/04
to
Thanks
Changed it to: outputval CInt("&H" & inputval)
That worked

> Just translate it into integer and back to string:
>
> CStr(CInt("&H123F"))
>
> ("&" at end is not needed)
>
> or just
>
> CInt("&H123F")
>
> //------------------------------------
> Regards,
> Vassiliev V. V.
> http://www-sharp.com -
> Scripting/HTA/.Net Framework IDE
>
> "srudenko" <srud...@mail.ev1.net>

ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ ×
> ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ:


news:40abb978.594.41@news2...
> > Does VBScript have an equivalent of visual basic Val()
> > function?
> > Trying to convert HEX to DEC so using something like

> > this: txtoutput Val("&H" & txtInput & "&")


> >
> > VBScript keeps on saying Type Mismatch Val
> >
> >
> > Steve, I-Net+
> > http://www.webzila.com
> >
>
>


Steve, I-Net+
http://www.webzila.com

tomthumbkop

unread,
May 19, 2004, 5:36:09 PM5/19/04
to

I believe what you want is:
txtoutput = Hex(txtInput)

srudenko wrote:
> *Does VBScript have an equivalent of visual basic Val()

> http://www.webzila.com *

--
tomthumbkop
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

srudenko

unread,
May 19, 2004, 7:12:16 PM5/19/04
to
txtoutput = Hex(txtInput) would convert the txtInput to a
Hexadecimal value but I was trying to get it the other way
around ... from Hex to Dec

I got it working with the CInt code...


Steve, I-Net+
http://www.webzila.com

0 new messages