-1

Overflow Error 6

Public enum eLogLocations
  inListBox = 2&
  inDebug = 4&
  inFile = 8&
  Everywhere = inListBox & inDebug & inFile
end enum

I use numbers directly but same error... and the overflow come from the if evaluation not what after Then

The overflow occurs only when bitand return 0 I think. When debugging on this line, running the same line in debug windows never overflow. When using Everywhere or inFile never overflow.

as 4  =  100
and 8 = 1000
result= 0000

Another weird thing ! As bit manipulation must be held against integral type BUT the Bitand function takes two double as parameters and return also a double ?!?

Maybe I just missunderstood bitand usage...

8
  • 2
    Please post enough example code for us to reproduce the problem - it works fine for me but I'm not using your exact code... As for why it takes arguments of type double - likely because that datatype can accommodate larger values. Commented May 6 at 18:49
  • Shouldn't it be Everywhere = inListBox Or inDebug Or inFile ie 1110 = 14 Commented May 6 at 18:50
  • I just realize that the & will give 248 as value for Everywhere... not correct, also try + wich result in 14 like you said with OR but overflow... also tried 16& but also overflow... Commented May 6 at 19:15
  • 2
    Re your comment & will give 248 thats because & is the string concatenation operator. Commented May 6 at 20:11
  • Are you saying that evaluating WorksheetFunction.Bitand(8, 4) (as is) in VBA gives you 'Overflow'? this is not the case for me; time to restart EXCEL or re-boot. Also you might mean Everywhere = inListBox OR inDebug OR inFile Commented May 7 at 0:33

1 Answer 1

0
Public Function BinaryReverse(ByRef pNumber As Variant) As Variant
 If IsNumeric(pNumber) = False Then Exit Function
 With WorksheetFunction
  BinaryReverse = .Bin2Dec(StrReverse(.Dec2Bin(pNumber)))
 End With
End Function

Thanks to all contributors... with your help, anything possible !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.