Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You create a variable with a Dim Statement.
To create a new variable
Declare the variable in a
Dimstatement.Dim newCustomerInclude specifications for the variable's characteristics, such as Private, Static, Shadows, or WithEvents. For more information, see Declared Element Characteristics.
Public Static newCustomerYou do not need the
Dimkeyword if you use other keywords in the declaration.Follow the specifications with the variable's name, which must follow Visual Basic rules and conventions. For more information, see Declared Element Names.
Public Static newCustomerFollow the name with the As clause to specify the variable's data type.
Public Static newCustomer As CustomerIf you do not specify the data type, it uses the default:
Object.Follow the
Asclause with an equal sign (=) and follow the equal sign with the variable's initial value.Visual Basic assigns the specified value to the variable every time it runs the
Dimstatement. If you do not specify an initial value, Visual Basic assigns the default initial value for the variable's data type when it first enters the code that contains theDimstatement.If the variable is a reference type, you can create an instance of its class by including the New Operator keyword in the
Asclause. If you do not useNew, the initial value of the variable is Nothing.Public Static newCustomer As New Customer