【VFB】VisualFreeBasic:VisualBasic6望尘莫及之变量初始
VisualBasic6:微软出品、简单易用,虽然几十年前的,依旧生命顽强,以下简称:VB6VisualFreeBasic:集合VB6的易用和采用c语言的优点及编程底层操作,VB6高手的进阶语言,以下简称:VFB
变量初始化,当声明一个变量时,B语言会初始化它,数字的为0,字符的为空。
VB6:Dim A As Long '默认初始为0且只能是0
VFB:Dim A As Long = 100'可以随意初始为任意值。
其它例题:
Dim A As Long = 100 * 8 + 99 '可以是表达式
Dim A As Long = 函数(aaa)'可以是函数返回
定长数组初始化赋值:
Dim bb(3) As Long = {1, 2, 3, 4}
不定长度数组初始化赋值:
Dim cc(...) As String ={"1", "2", "3", "4", "5"}
多维数组初始化赋值:
Dim ee(1 To 2,1 To 5) As Long = {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}
自定义类型初始化赋值:Type MyType
var1 As Double
var2 As Integer
var3 As String
End Type
Dim MyVar(2) As MyType = {(1.0, 1, "Hello"), (2.0, 2, "GoodBye")}
注意:对于模块级,静态或全局变量,初始化值必须是常量表达式。
重新排版by @0xAA55
感谢楼主分享~~~
页:
[1]