|
-
Aug 17th, 2001, 04:18 AM
#1
Thread Starter
Member
2 Dimensional Array
Can I redimension 2D array in VB with using preserve? This is happening with Single Dimension array but not with 2 Dimensional array. The error was Subscript out of Range. codes goes like this.
Option Explicit
Dim showarr() As String
Dim rctr As Integer
Dim cctr As Integer
Private Sub Command1_Click()
ReDim showarr(1 To 4, 1 To 4) As String
For rctr = 1 To 4
For cctr = 1 To 4
showarr(rctr, cctr) = "row = " & rctr & " " & "Col = " & cctr
Next
Next
End Sub
Private Sub Command2_Click()
ReDim Preserve showarr(1 To 8, 1 To 4) As String
For rctr = 5 To 8
For cctr = 1 To 4
showarr(rctr, cctr) = "row = " & rctr & " " & "Col = " & cctr
Next
Next
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|