Posted by: Sourav | March 11, 2014

Redimentioning arrays in VB 6.0


Private Sub Command1_Click()

Dim numbers() As Integer

ReDim numbers(0 To 5) As Integer

numbers(0) = 10

numbers(1) = 20

numbers(2) = 30

numbers(3) = 40

numbers(4) = 50

numbers(5) = 60

Dim l As Integer

Text1.Text = “”

Dim a As Integer

a = UBound(numbers)

Print a

Dim loc As Integer

loc = 2

ReDim Preserve numbers(UBound(numbers) + 1) As Integer

For i = (UBound(numbers) – 1) To (loc – 1) Step -1

numbers(i + 1) = numbers(i)

Next i

numbers(loc – 1) = 15

For i = 0 To (UBound(numbers))

Text1.Text = Text1.Text + Str(numbers(i)) + vbCrLf

Next i

End Sub

 

http://patorjk.com/programming/tutorials/vbarrays.htm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: