Proper Way to Pass an Int

mtairhead

Registered User.
Local time
Today, 05:20
Joined
Oct 17, 2003
Messages
138
What is the proper way to pass an integer?

I have this function and sub:
PHP:
Public Function testpassing(number3 As Integer)
    testpassing = number3 + 20
End Function

Public Sub test()
    Dim test2 As Integer
    test2 = 189704
    msgbox(testpassing (test2))
End Sub

...But I get an overflow error when I run test().

I suspect it's how I pass the variable.

~Andrew
 
Its a question of typing. max value for an integer is 32K or there abouts. Use Long instead and everything will work fine
 
Your passing the value quite correctly but an integer can only have a value between -32,768 and 32,767. If you dim 'test2' and 'number3' as 'long' or 'double' you shouldn't have any problems.
 
Most excellent! Thanks!

I really ought to get myself a book.
 

Users who are viewing this thread

Back
Top Bottom