Question Get data entered in sequance(arrays)

Jimbo84

New member
Joined
Dec 8, 2011
Messages
4
Programming Experience
Beginner
Hi,

I have a predefined code(which may not be changed), and by user entered values remembered and display this data like in output below.
Does anyone have any idea to write additional methods or functions for getting this output?

Predefined code:
VB.NET:
Module ArraysDataRemember
   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
   '...
End Module



Output should be(also with Count and Capacity):
VB.NET:
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 ? :
 
So basically you've been set a task (homework?) to provide the extra methods needed to make this work and you've come here to get someone else to do it for you.

These forums exist to help coders with problems and hurdles they've encountered with VB.Net - there are a lot of folk here willing to impart their knowledge and experience, but they'll help you to help yourself, rather than hand you a complete solution to your "I need to do this..." post.

So have a crack at this yourself and come back if you run into problems. At the very least identify the methods you need to create and add that code to your module. Everything is there to tell you what those methods are called, what values they should accept and what they should return (if needed).

I'll even give you a head-start... you have three methods to create.
 
At this point what I have is the following(defined 3methods and added count):

Module ArraysDataRemember
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


Capacity doesn't seem to work, should assume this needs to be processed in the 2nd method?

PS.: I can't put this code via a Code sign in my reply... does anyone know how?
 
It's going to be hard for anyone to help if you don't include your full code - at the moment your code won't even compile without an error.

Use the :

[ CODE ]...[/ CODE ] (without the extra spaces)

to format your code.
 
It's going to be hard for anyone to help if you don't include your full code - at the moment your code won't even compile without an error.

Use the :

[ CODE ]...[/ CODE ] (without the extra spaces)

to format your code.

Thanks for advising the Code issue.

Previous given code is able to run in Visual Studio, without any errors.
I just don't know how to get the the methods for getting my output.

My code now:
VB.NET:
Module GequoteerdeOefening07
    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
 
Your code is still going to give an error when compiled and Visual Studio will be telling you exactly where that

What are you actually asking for help with? You've created no code other than the bare functions... are you expecting someone to fill in the code?

Work out what you need to do, then take a shot at writing the code to accomplish it - it's fairly obvious that this is some sort of task that's intended to improve your coding skills, so go ahead and improve them! Trial and error are great tutors.

If you actually run into problems with your code, you'll likely find help here... at the moment, you have no code to help with.
 
Back
Top