ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What does an ampersand mean in VBA? (https://www.excelbanter.com/excel-programming/283146-what-does-ampersand-mean-vba.html)

J S

What does an ampersand mean in VBA?
 
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



Chip Pearson[_2_]

What does an ampersand mean in VBA?
 
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


"J S" wrote in message ...
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





Steve Garman

What does an ampersand mean in VBA?
 
J S wrote:
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.



All times are GMT +1. The time now is 05:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com