Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VB6, do declared fields have default values?

Tags:

vb6

I am going through some old VB6 code and in many forms, I encounter declaration statements like -

 PEC_NUM_ENT(1) As Byte
 EC_MORE_RW_EXIST(0) As Byte
 EC_CODE_IND(0) As Byte
 EC_DATA(7) As PRXDetail 

My question is, do these fields have default values? If so, what are the values? Thanks.

like image 611
CodeBlue Avatar asked Apr 06 '12 14:04

CodeBlue


People also ask

What is the default value of an object's reference type field?

The default value of a reference type is null . It means that if a reference type is a static class member or an instance field and not assigned an initial value explicitly, it will be initialized automatically and assigned the value of null .

What is the default value of a variable declared as Boolean data type?

The default value of Boolean is False .

What is the purpose of default value field property?

You add a default value to a table field or form control whenever you want Access to enter a value in a new record automatically. For example, you can have Access always add the current date to new orders. Typically, you add a default value to your table fields.

How entry required and default value properties of a table field in a database are different from each other?

1 Answer. Entry Required – if set to yes then it will be necessary for the user to insert the value in the field which means that field cannot be left blank. Default Value – A default value can be set for a field if user don't provide any value while entering the values in the table.


2 Answers

Yes. Numerical and date types default to 0, strings to an empty string (i.e., ""), boolean to False, and variant to EMPTY.

like image 177
mdoyle Avatar answered Sep 20 '22 16:09

mdoyle


From the VB6 documentation

When variables are initialized, a numeric variable is initialized to 0, a variable-length string is initialized to a zero-length string (""), and a fixed-length string is filled with zeros. Variant variables are initialized to Empty. Each element of a user-defined type variable is initialized as if it were a separate variable.

PRXDETAIL looks like it might be a user-defined type

like image 21
MarkJ Avatar answered Sep 22 '22 16:09

MarkJ