how can i convert these C line:

(py>>6)<<6)

to VB6?

Recommended Answers

All 6 Replies

VB6 doesn't support <<. As best I can determine, the C code is shifting bits to the right, then back to the left, effectively clearing the lower 6 bits.

In VB6, you can do the same by:

Dim py As Long
Dim shiftedValue As Long
shiftedValue = py / (2 ^ 6) ' Shift right by 6 positions
shiftedValue = shiftedValue * (2 ^ 6) ' Shift left by 6 positions

Likely, someone could write more efficient code, but this seems to work.

commented: thank you so much for all to all +7

Glad you were able to work it out. Why are you still using VB6?

commented: why you are, always, tell me that? i have installed the VS2022, but it's very slow... even for create and run a project... for now i still with VS98.. +7

I always recommend ditching VB6. It is super old technology. If you were using Python 2.x I would also advise moving to Python 3.x for the same reason. If you stick with the old you will be left behind. If I were a potential employer I would not hire anyone who only worked in old tech except for the very rare case when it is required to maintain legacy code like COBOL. It would not surprise me in the least if upcoming versions of Windows would not even run VB6 programs.

commented: now i get.. thanks for all +0

Reverend Jim: i installed the VS2010.. seems much more faster on my laptop ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.