Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Arrays + methods

Jimbo84Jimbo84 Member Posts: 4
Hi,

How can I put an Array with Doubled Capacity(in same output as below), at the moment I have added 3 methods. But not fully working. Values should be what the user is able to enter, and is memorized in the next sentence. Sub Main may not be changed.

[code]Running program: 'complete output
Values (count=0/capacity=2) :
Value ? : 10
Values (count=1/capacity=2) : 10
Value ? : 20
Values (count=2/capacity=2) : 10 20
Value ? : 30
Values (count=3/capacity=4) : 10 20 30
Value ? : 40
Values (count=4/capacity=4) : 10 20 30 40
Value ? : 50
Values (count=5/capacity=8) : 10 20 30 40 50
Value ? : 60
Values (count=6/capacity=8) : 10 20 30 40 50 60
Value ? : 70
Values (count=7/capacity=8) : 10 20 30 40 50 60 70
Value ? : 80
Values (count=8/capacity=8) : 10 20 30 40 50 60 70 80
Value ? : 90
Values (count=9/capacity=16) : 10 20 30 40 50 60 70 80 90
Value ? : [/code]


My current code:
[code]Module Arrays
Sub Main()
Dim count As Integer = 0
Dim values(1) As Integer
Do
PrintValues(values, count)
'
Console.Write("Value ? : ")
Dim newValue As Integer = Console.ReadLine()
count += 1
'
If count > values.Length Then
values = GetArrayWithDoubledCapacity(values)
End If
'
StoreValue(values, newValue, count - 1)
Loop
'
Console.ReadLine()
End Sub
Function PrintValues(ByVal values As Integer(), ByVal count As Integer)
Console.WriteLine("Values (count=" & count + 1 & "/capacity=")
Return values
End Function
Function GetArrayWithDoubledCapacity(ByVal values As Integer())

Return values
End Function

Function StoreValue(ByVal values As Integer(), ByVal newValue As Integer, ByVal Count As Integer)

Return values
End Function


End Module[/code]
Sign In or Register to comment.