调用sub无效,并一直说“未为参数指定参数”

时间:2019-04-15 16:38:10

标签: arrays vb.net parameters

我尝试使用PromptUser中Sub Sub Main中的值,但不能。它说:

  

未为参数SaS指定参数
  未声明EmailAddress,StudentName,SaS,并且由于保护级别可能无法访问

StudentNameEmailAddressSaS是数组:

Module Module1
Private StudentName(2) As String
Private EmailAddress(2) As String
Private SaS(2) As String
    Public Sub PromptUser(ByVal StudentName() As String, ByVal EmailAddress() As String, ByVal SaS() As String)

        For i = 0 to 2
            Console.WriteLine("enter your name: ")
            StudentName(i) = Console.ReadLine()
            Console.WriteLine("enter your e-mail")
            EmailAddress(i) = Console.ReadLine
            SaS(i) = StudentName(i) & "#" & EmailAddress(i)
        Next
    End Sub
    Sub Main()
        Dim SSN1 As String
        PromptUser(StudentName(), EmailAddress(), SaS())
        For i = 0 to 2
            Console.WriteLine("enter name to search: ")
            SSN1 = Console.ReadLine()
            If SSN1 = StudentName(i) Then
                Console.WriteLine(SaS(i))
            End If
        Next
    End Sub
End Module

0 个答案:

没有答案