Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21162

[RESOLVED] Automatic addition of '#' when assigning variable value

$
0
0
This seems like a very simple problem that I can't find any information on. A simplified version of the code - I have a larger script as part of a maths problem which uses the number '6008514752' as an input:

Code:

Dim x As Variant

x = 6008514752#

Debug.Print x Mod 2

This returns an Overflow error. Why does VB6 add the '#' automatically to this number? I understand that this forces x to be a double, and from what I've been reading some operations in VB require double accuracy. I used 'Variant' because the number is outside the 9-digit range for 'Long'. Should I be using something else? Does it matter here?

I'm also confused as to why

Code:

Debug.Print x
does not return an overflow if the mod operator does.

Viewing all articles
Browse latest Browse all 21162

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>