Working with Bits in VBA

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Hello,
I have two questions relating to the sizes of variables in VBA.

I've been just looking at Ruddle's code in this thread (Algorithm Question)
http://www.mrexcel.com/forum/showthread.php?t=566351

and I started to wonder if we could work with bits in VBA in any ways just like from C++?
http://www.cplusplus.com/reference/stl/vector/


Moreover, this led to a new question which I had not known until now.
Why does a boolean take up 2 BYTES!!!! in VBA?
as stated in http://www.ozgrid.com/VBA/variables.htm

Thank you in advance,
Kpark.
 
I'd forgotten that you can use And and Or to do bit-wise operations. I shall have to revisit that horrible code...
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Ruddles,
A suggestion about IncrimentString

Code:
Dim firstZero as Long
FirstZero = InStr(binaryString & "0", "0")
IncrimentedString = String(FirstZero, "0") & "1" & Mid(binaryString, FirstZero + 1)
 
Upvote 0
If you are looking for something like BASIC's POKE and PEEK commands, Mac can't do that. Are you on a Windows machine? If so, I've got a link (at home) that might help you.

Or are you looking for VBA commands that work at the level of an assembly language? (sorry, no)

I am on a Windows machine.
It'd be cool to see the link if you don't mind please.

and... nope about the assembly level O_o
I don't even know how it works really..
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top