Mathematical operation in vb scripts

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
PMJ
Posts: 13
Joined: Mon 9. Jan 2012, 12:44

Mathematical operation in vb scripts

Post by PMJ » Thu 17. Jul 2014, 09:18

Hello.
Is it possible in VBS macro modulo operation, hex to dec and dec to hex????

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Mathematical operation in vb scripts

Post by K.Wolf » Thu 17. Jul 2014, 16:06

Yes, all that is possible.

Modulo:

Code: Select all

Dim A
A = 16 Mod 5
MsgBox A
The result is 1.

hex -> dec conversion:

Code: Select all

Dim d
d = 255
MsgBox Hex(d)
The result is FF.

dec -> hex conversion:

Code: Select all

Dim h
h = "&HFF"
MsgBox CInt(h)
h = &HFF
MsgBox h
The result is in both cases 255.

PMJ
Posts: 13
Joined: Mon 9. Jan 2012, 12:44

Re: Mathematical operation in vb scripts

Post by PMJ » Fri 18. Jul 2014, 09:13

Hello,

thanks it's works.

I have second problem. I need write to ex. x=2 200 000 000. In this moment i have comunicate x overflow.
In my opinion the best solution is a change x to double but i don't how.

K.Wolf
Software Development
Software Development
Posts: 141
Joined: Wed 22. Sep 2010, 15:37

Re: Mathematical operation in vb scripts

Post by K.Wolf » Fri 18. Jul 2014, 11:58

You can assign large values to VBS variables without errors and calculate something with it, the VBS scripting engine then internally works with floating point numbers (double). But many functions in VBS are limited to signed 32-bit integer values, the highest value of which is 2147483647.

Post Reply