Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

VBA Code, what's the "&" about in a variable declaration?

  • 12-01-2012 11:53AM
    #1
    Registered Users, Registered Users 2 Posts: 3,438 ✭✭✭


    Hi folks,

    Believe it or not, this is my own code from years ago. I'm trying to figure out what I was doing with the variable c& ? What is the ampersand about? Is it a pointer or something?
    Public Function HasExistingLoan(CustomerID As Integer) As Boolean
    
    On Error GoTo errHand
    
    [B]Dim sql As String, c&
    [/B]
    sql = "SELECT COUNT(customer_id) " & _
            "FROM loans " & _
            "WHERE customer_id =" & CustomerID & _
            " AND end_time Is Null AND end_station Is Null"
    
    c = CurrentProject.Connection.Execute(sql).Collect(0)
    HasExistingLoan = (CInt(c) > 0)
    
    Exit Function
    
    errHand:
    HasExistingLoan = -1
    
    End Function
    


Comments

  • Registered Users, Registered Users 2 Posts: 3,438 ✭✭✭dnme


    To answer my own question, I think it forces a type of "long" rather than 16bit int to the variable c. If true it's just shorthand and I don't know why I didn't use "Dim c as long" instead for readibility. Am I on the right track?


  • Registered Users, Registered Users 2 Posts: 2,157 ✭✭✭dazberry


    dnme wrote: »
    Am I on the right track?

    It would appear so:

    http://msdn.microsoft.com/en-us/library/s9cz43ek.aspx

    D.


Advertisement