在VB中,可以使用以下方式声明变量:
Dim
:Dim variableName As DataType
例如:Dim age As Integer
Static
:Static variableName As DataType
例如:Static counter As Integer
Public
:Public variableName As DataType
例如:Public name As String
Private
:Private variableName As DataType
例如:Private balance As Double
Friend
:Friend variableName As DataType
例如:Friend count As Integer
Const
:Const variableName As DataType = value
例如:Const PI As Double = 3.14159
注意:在声明变量时,需要指定变量的数据类型。常见的数据类型包括整数(Integer)、浮点数(Double、Single)、字符串(String)、布尔值(Boolean)等。