這裏是一些代碼來創建數組:
Dim a(1 To 5, 1 To 5) As Integer
Private Sub SetRing(lvl As Long, dimSize As Long, value As Long)
Call SetHValues(lvl, dimSize, value)
Call SetVValues(lvl, dimSize, value)
End Sub
Private Sub SetHValues(lvl As Long, dimSize As Long, value As Long)
Dim i As Long, k As Long
If lvl > (dimSize/2) + 1 Then Exit Sub
For i = lvl To dimSize - lvl + 1
' horizontal values'
a(lvl, i) = value
a(dimSize - lvl + 1, i) = value
Next
End Sub
Private Sub SetVValues(lvl As Long, dimSize As Long, value As Long)
Dim i As Long, k As Long
If lvl > (dimSize/2) + 1 Then Exit Sub
For i = lvl To dimSize - lvl + 1
' vertical values'
a(i, lvl) = value
a(i, dimSize - lvl + 1) = value
Next
End Sub
以及創建樣本數組,你會打電話:
Call SetRing(1, 5, 100)
Call SetRing(2, 5, 105)
Call SetRing(3, 5, 110)
要創建一個數組在Visual Basic中您可以使用 暗淡simpleContour(5 ,5)As Integer 但你的問題似乎是如何獲得該數組中的值。我對嗎? – dirbacke 2010-11-11 13:41:57
是的,你是對的。事實上,我已經宣佈了一切,但我只需要按照我解釋的方式存儲價值的方式。謝謝! – 2010-11-11 13:59:45