Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using defined types

Status
Not open for further replies.

steveB2006

Programmer
Feb 13, 2006
11
CA
I am trying to implement a "struct" or user-defined type where I can implicitly name but cannot implement with the NEW keyword. I have resorted to an array structure

Code:
Option Explicit
Public Type InvoiceRecord
    ID as Integer
    invDate as Date
End type

Public Function loadStruct()

    Dim invRcd(1 to 5) as InvoiceRecord
    Dim i as integer
    Dim rcdDate as Date

    rcdDate = Date

    For i = 1 To 5 Step 1
        
        incRcd(i).ID = i
        invRcd(i).invDate = rcdDate
        MsgBox "invRcd" & i & "ID is " & invRcd(i).ID
        MsgBox "invRcd" & i & "Date is " & invRcd(i).invDate
        rcdDate = rcdDate + 1
    Next
End Function

I would prefer to declare a new struct for each record simply giving each a new name like struct10 and accessing the data by address rather than using the array method. However I cannot create the struct using either statements:

Code:
Dim bla as New InvoiceRecord
'or
Set bla = New InvoiceRecord

I could be that I may require a library reference also under the tools menu. Any ideas??

thanks,
steveB




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top