User Defined Types (UDTs) are a convenient way to store related data in one variable. The most useful way one can use UDT to pass information between procedures. Here is a simple example of how to use UDT. The type statement is used to define UDT and must be outside of any procedures.
Option Explicit
Private Type Applicant
firstname As String
lastname As String
resumerecvd As Boolean
interviewdate As Date
End Type
Sub defineUDT()
Dim myapp As Applicant
myapp.firstname = "Soumyendu"
myapp.lastname = "Choudhury"
myapp.resumerecvd = True
myapp.interviewdate = #7/15/2011#
useUDT myapp
End Sub
Sub useUDT(myInput As Applicant)
MsgBox myInput.firstname
MsgBox myInput.lastname
MsgBox myInput.resumerecvd
End Sub
No comments:
Post a Comment