Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 12-01-2012 10:53am
    #1
    Registered Users, Registered Users 2 Posts: 3,429 ✭✭✭


    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,429 ✭✭✭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,152 ✭✭✭dazberry


    dnme wrote: »
    Am I on the right track?

    It would appear so:

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

    D.


Advertisement