• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Advanced VBA Techniques > What Are User-Defined Types, and Why Woul...

What Are User-Defined Types, and Why Would You Use Them?

A user-defined type, known as a struct or record, allows you to create a variable containing several pieces of information. You will often use user-defined types to hold information from one or more records in memory. You can also use them to hold related information that you would otherwise store in several unrelated variables. Because you can instruct each element of a user-defined type to hold a particular type of data, you can define each element in the type to correspond to the type of data stored in a specific field of a table. A user-defined type might look like this:

Public Type TimeCardInfo
   TimeCardDetailID As Long
   TimeCardID As Long
   DateWorked As Date
   ProjectID As Long
   WorkDescription As String * 255
   BillableHours As Double
   BillingRate As Currency
   WorkCodeID As Long
End Type


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint