Dim b As Long = 5 1024 1024 * 1024
Why it's not right?
Dim b As Long = 5 1024 1024 * 1024
Why it's not right?
Dim a As Long = 5368709120 'No problem
Dim b Long = 5 * 1024 * 1024 * 1024 'It's not compile
(5*1024*1024*1024 = 5368709120)
5 and 1024 are interpreted as Integer. The “*” operation for such values is also limited to Integer by VB, but the result is larger than the maximum value of Integer, therefore it cannot be computed. If you add “L” to any term, the value and the result becomes a Long, which is enough for 5GB. The “L” suffix is not required in case of 5368709120 because it is clear that this is a large, Long value.
Try this:
Dim b As Long = 5 * 1024L * 1024 * 1024
10 people are following this question.