What does an ampersand mean in VBA?

J

J S

I know that an ampersand is generally used as the concatenation operator but
I seemed to have found another usage of it that I don't understand. Here is
a code snippet:

Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("2:", "scott/tiger", 0&)
Set EmpDynaset = OraDatabase.DbCreateDynaset("select * from emp", 0&)

Notice the parameters 0&, what does the & do? Based on the documentation I
would have just put a zero instead of a 0&.

-J
 
C

Chip Pearson

In this context, the & character makes the number a Long type value, rather
than an Integer.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
S

Steve Garman

J said:
I know that an ampersand is generally used as the concatenation operator but
I seemed to have found another usage of it that I don't understand. Here is
a code snippet:

Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("2:", "scott/tiger", 0&)
Set EmpDynaset = OraDatabase.DbCreateDynaset("select * from emp", 0&)

Notice the parameters 0&, what does the & do? Based on the documentation I
would have just put a zero instead of a 0&.

It forces the 0 to be a long instead of an integer.
This ensures that the correct type of variable is passed as the Oracle
procedure argument.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top