我的程序的目标是通过调用主过程中的子过程来初始化一维数组。但是,我在初始化for循环中的“TestScores”中得到一个错误,表达式不是数组或方法。我在main函数中声明TestScores是一个上限为10的数组。我做错了什么?
'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
答案 0 :(得分:1)
你的方法是将TestScores作为Double,而不是双打数组。
Sub InitializeArray(ByRef TestScores As Double)
应该是
Sub InitializeArray(ByRef TestScores() As Double)
还需要对所有其他潜艇进行此更改。