在VB中,给数组赋值有多种方式。以下是一些常见的方法:
Dim arr(5) As Integer
For i As Integer = 0 To arr.Length - 1
arr(i) = i + 1
Next i
Dim arr() As Integer = New Integer() {1, 2, 3, 4, 5}
Dim list As New List(Of Integer)()
list.Add(1)
list.Add(2)
list.Add(3)
Dim arr() As Integer = list.ToArray()
Dim oldArr() As Integer = {1, 2, 3}
ReDim arr(oldArr.Length) ' 调整数组大小
For i As Integer = 0 To oldArr.Length - 1
arr(i) = oldArr(i)
Next i
请根据您的具体需求选择适合的方法。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: vb判断语句的用法是什么