0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

2次元配列をReDimする

Posted at

うん、馬鹿馬鹿しいね。でも、VB6 からコンバートしてたら、そんなソースができちゃったんだ

で、関数作った。

    Public Sub Redim2(Of t)(ByRef array(,) As t, w As Integer, h As Integer)
        If array Is Nothing Then
            ReDim array(w, h)
        ElseIf array.GetUpperBound(1) < h Then
            ReDim Preserve array(array.GetUpperBound(0), h)
        ElseIf array.GetUpperBound(0) < w Then
            Dim newarray(,) As t = New t(w, array.GetUpperBound(1)) {}
            For i As Integer = 0 To array.GetUpperBound(0)
                For j As Integer = 0 To array.GetUpperBound(1)
                    newarray(i, j) = array(i, j)
                Next
            Next
            array = newarray
        End If
    End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?