0

Hi, my teacher has set me a challenge to create an array that gets the user to input 6 names, then it will output the 6 names to them. It sounds simple, but he set it to me knowing that I had no knowledge on how to actually do this. I had only learnt about arrays that day when he spent 5 minutes briefly telling me what they were used for. But that's about it.
I have spent a long time now trying to figure it out, so if someone could point me in the right direction that'd be great...

Module Module1

Sub Main()

    Dim Name(6) As String
    Dim Response As String

    Name(0) = "Aaria"
    Name(1) = "Abihu"
    Name(2) = "Charlotte"
    Name(3) = "Mia"
    Name(4) = "Lilly"
    Name(5) = "Drake"
    Name(6) = "Seth"

    For counter = 0 To 6
        Console.Write("Please write a name: ")
        Response = Console.ReadLine()
        counter = counter + 1 - 1
        '  Console.WriteLine(counter)   ' Use this to check if the counter if working correctly   
    Next

    For Count As Integer = 0 To 6

        Console.WriteLine(Name(Count))
        Count = Count + 1 - 1
    Next

    Console.ReadLine()

End Sub

End Module

It'd been edited so much now it's just a mess that no longer really makes sense...

2
Contributors
2
Replies
9
Views
4 Years
Discussion Span
Last Post by emma.brady.794
0

Delete lines 17 and 24 -- the variable Count is changed by lines 14 and 21

delete line 6 to 12 because the user is supposed to enter those strings.

line 16: You don't need the string Response. Just use the array

Name(count) = Console.ReadLine()

So your program should look something like this:

Sub Main()

    Dim Name(6) As String

    For counter = 0 To 6
        Console.Write("Please write a name: ")
        NameO(counter) = Console.ReadLine()
    Next

    For Count As Integer = 0 To 6
        Console.WriteLine(Name(Count))
    Next

    Console.ReadLine()

End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.