在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
请根据您的具体需求选择适合的方法。