Question:
How can I convert a decimal value into binary?
Solution:
To convert these values, you must divide the first one by 2, then take the rest (always 0 or 1) and concatenate this digit to the binary number, to the left. Repeat this process as many times as necessary until the original value is smaller than 2.
In vbScript, the operator calculating the rest in a division is called Mod. See a sample script below:
my_value = InputBox(“Type the desired value in decimal format:”)
Â
binary_value = “”
while my_value >= 2
              binary_value = (my_value Mod 2) & binary_value
              my_value = int(my_value / 2)
wend
binary_value = my_value & binary_value
Â
MsgBox binary_value
