在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
請根據您的具體需求選擇適合的方法。