Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    milton keynes, Buckinghamshire
    Posts
    252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    structures as variables (2000)

    If my memory is correct in c++ I used to write code to create an array of structures which goes something like this:

    struct GLTransfer
    {
    long GLcode
    string GLAcctName
    string GLSection
    }

    GLTransfer (50)

    Can excel VBA create similar structures and if so can you let me have a note of the syntax

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: structures as variables (2000)

    VBA uses the keyword Type for this.

    Type EmployeeRecord ' Create user-defined type.
    ID As Integer ' Define elements of data type.
    Name As String * 20
    Address As String * 30
    HireDate As Date
    End Type

    Dim arrEmployees(50) As EmployeeRecord

    You can then use (for instance)

    With arrEmployees(37)
    .ID = 1234
    .Name = "John Doe"
    .Address = "60, Richardson Rd"
    .HireDate = #01/01/1999#
    End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •