0

The goal of my program is to initialize a one-dimensional array through calling a sub-procedure in the main procedure. I get an error, though, on "TestScores" in my initializing for loop that the expression is not an array or method. I have it declared in the main function that TestScores is an array with an upper-bound of 10. What am I doing wrong?

'Author: Michael Barney
Option Explicit On
Option Strict On

Module Module1

    Sub Main()

        Dim Index As Integer
        Dim TestScores(10) As Double

        InitializeArray(TestScores)
        PrintArray(TestScores)

        LoadArray(TestScores)
        PrintArray(TestScores)

        SearchArray(TestScores)

    End Sub


    Sub InitializeArray(ByRef TestScores As Double)
        Console.WriteLine("Entering: -----------------------> InitializeArray")
        Dim Index As Integer

        For Index = 0 To 10
            TestScores(Index) = 0.0
        Next Index

        Console.WriteLine("Exiting: -----------------------> InitializeArray")
    End Sub



    Sub PrintArray(ByVal TestScores As Double)
        Console.WriteLine("Entering: -----------------------> PrintArray")
        'Your code goes here...
        Console.WriteLine("Exiting: -----------------------> PrintArray")
    End Sub



    Sub LoadArray(ByVal TestScores As Double)
        Console.WriteLine("Entering: -----------------------> LoadArray")
        'Your code goes here...
        Console.WriteLine("Exiting: -----------------------> LoadArray")
    End Sub



    Sub SearchArray(ByVal TestScores As Double)
        Console.WriteLine("Entering: -----------------------> SearchArray")
        'Your code goes here...
        Console.WriteLine("Exiting: -----------------------> SearchArray")
    End Sub



End Module

1 Answer 1

1

You're method is taking TestScores as a Double, not as an array of Doubles.

Sub InitializeArray(ByRef TestScores As Double)

Should be

Sub InitializeArray(ByRef TestScores() As Double)

This change will also need to be made to all your other subs as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.