dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Mar 16, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Initializing Array of UDT's

Question:
Here's some simple code in Test.bas:
Public Type MY_RECORD
    Field1 as String
    Field1 as String
End Type

in frmTest.frm
General Declarations
Private mArrayOfRecords() as MY_RECORD


Form_Load
    'this line of code BOMBS
    If IsEmpty(mArrayOfRecords) then
        'dimension it
    End If
End Sub
OK, Why can't I check if an array of user defined types has been initialized? IsEmpty does not work, nor does TypeName, VarType or any other type checking function. I get errors when I attempt to check the state of an un-initialized array of UDT's. Any explanations?

Answer:
Typically, UDT members are initialized the same way that regular variables of the same type are (i.e., strings are empty strings, numbers are zero, etc.).

The best way to check your UDT is to either check the individual members or to add an extra member that can hold a true/false value to indicate if the UDT has been initialized.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date