Como: Criar uma nova variável (Visual Basic)
You create a variable with a Instrução Dim (Visual Basic).
To create a new variable
Declare the variable in a Dim statement.
Dim newCustomer
Include specifications for the variable's characteristics, such as Private (Visual Basic), Static (Visual Basic), Shadows (Visual Basic), or WithEvents (Visual Basic). For more information, see Características do elemento declarado (Visual Basic).
Public Static newCustomer
You do not need the Dim keyword 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 Nomes de elementos declarados (Visual Basic).
Public Static newCustomer
Follow the name with the As clause to specify the variable's data type.
Public Static newCustomer As Customer
Se você não especificar o tipo de dados, ele usa o padrão: Object.
Follow the As clause 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 Dim statement. 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 the Dim statement.
If the variable is a reference type, you can create an instance of its class by including the operador New (Visual Basic) keyword in the As clause. If you do not use New, the initial value of the variable is Nada (Visual Basic).
Public Static newCustomer As New Customer
Consulte também
Referência
Conceitos
Declaração de variável no Visual Basic
Nomes de elementos declarados (Visual Basic)
Características do elemento declarado (Visual Basic)
Inferência de tipo de variável local (Visual Basic)