Vb.net Visual Basic,应为语句结尾-函数

Vb.net Visual Basic,应为语句结尾-函数,vb.net,function,compiler-errors,Vb.net,Function,Compiler Errors,我一直在尝试修复我一直在处理的程序的“预期语句结束””错误时遇到问题。在我开始使用我称之为Payments的函数语句之前,其他一切似乎都正常工作。在这个函数中,我试图计算每个月的月数 我得到这个错误的确切位置是 While monthlyBal > 0 monthlyBal = Payments(tempBalances, monthlyRate) 我在下面添加了其余的代码 Module CreditCardCa

我一直在尝试修复我一直在处理的程序的“预期语句结束””错误时遇到问题。在我开始使用我称之为Payments的函数语句之前,其他一切似乎都正常工作。在这个函数中,我试图计算每个月的月数

我得到这个错误的确切位置是

While monthlyBal > 0                                
      monthlyBal = Payments(tempBalances, monthlyRate)
我在下面添加了其余的代码

Module CreditCardCalculator

    Sub DisplayCreditCards(ByVal cardNames() As String, ByVal cardAPRs() As Double, ByVal cardBalances() As Double)
        Const _SPACE As String = "     "
        Dim count As Integer = 1

        System.Console.WriteLine("The Order of Credit Cards To Pay Off")
        System.Console.WriteLine("------------------------------------")
        For pos = 0 To cardNames.Length - 1
            System.Console.WriteLine("Credit Card " & count & ": ")
            System.Console.WriteLine(_SPACE & "NAME: " & cardNames(pos))
            System.Console.WriteLine(_SPACE & "APRs: " & cardAPRs(pos) &"%")
            System.Console.WriteLine(_SPACE & "BALANCE: " & cardBalances(pos))
            System.Console.WriteLine()
            count = count + 1
        Next
    End Sub

    Sub OrderofCreditCards(ByRef cardNames() As String, ByRef cardAPRs() As Double, ByRef cardBalances() As Double, ByVal SIZE as Integer)  
        Dim firstInput As String
        Dim secondInput As String
        Dim swapNames(SIZE) As String
        Dim swapAPRs(SIZE) As Double
        Dim swapBalances(SIZE) As Double

        System.Console.WriteLine("Which Credit Card would you like to payoff first?")
        firstInput = Console.ReadLine()
        For pos = 0 To cardNames.Length - 1
            If firstInput = cardNames(pos) Then
                swapNames(0) = cardNames(pos) 
                swapAPRs(0) = cardAPRs(pos) 
                swapBalances(0) = cardBalances(pos)
                Exit For
            End If
        Next

        System.Console.WriteLine("Which Credit Card would you like to payoff second?")
        secondInput = Console.ReadLine()
        For pos = 0 To cardNames.Length - 1
            If secondInput = cardNames(pos) Then
                swapNames(1) = cardNames(pos) 
                swapAPRs(1) = cardAPRs(pos) 
                swapBalances(1) = cardBalances(pos)
                Exit For
            End If
        Next
        For pos = 0 To cardNames.Length - 1
            If cardNames(pos) <> swapNames(0) Then
                If cardNames(pos) <> swapNames(1) Then
                    swapNames(2) = cardNames(pos) 
                    swapAPRs(2) = cardAPRs(pos) 
                    swapBalances(2) = cardBalances(pos)
                    Exit For
                End If
            End If
        Next

        cardNames = swapNames
        cardAPRs = swapAPRs
        cardBalances = swapBalances         
    End Sub

    Sub DisplayMenu()
        System.Console.WriteLine("CREDIT CARD CALCULATOR MENU")
        System.Console.WriteLine("===========================")
        System.Console.WriteLine("OPTION 1. Display Total Number Of Payments Required To Pay Off Each 

Card. ")
        System.Console.WriteLine()
        System.Console.WriteLine("OPTION 2. Display The Number Of Years, Or Months To Pay Off Each Card. 

")
        System.Console.WriteLine()
        System.Console.WriteLine("OPTION 3. Display The Balance To Payoff Each Card and Total Amount To 

Payoff All Cards Combined. ")
        System.Console.WriteLine()
        System.Console.WriteLine("OPTION 4. Exit The Program. ")
        System.Console.WriteLine()
        System.Console.WriteLine

("=============================================================================")
        System.Console.WriteLine("Instructions: Type The Number That Is Next To The Option You Want To 

Execute. ")
    End Sub

    Function Payments(ByVal tempBalances As Double, ByVal monthlyRate As Double) As Double
        Const ISSUECHARGE As Integer = 3
        Dim avgMonthlyBal As Double 
        Dim interest As Double
        Dim minimumPayment As Double

        avgMonthlyBal = tempBalances
        interest = monthlyRate
        avgMonthlyBal = avgMonthlyBal + interest
        minimumPayment = avgMonthlyBal * ISSUECHARGE
        avgMonthlyBal = avgMonthlyBal - minimumPayment
        Return avgMonthlyBal
    End Function

    Sub Main()
        Const MAX_SIZE AS Integer = 2
        Const BILLPERIOD As Integer = 30
        Const MONTHSINYEAR As Integer = 12
        Dim creditCards(MAX_SIZE) As String
            creditCards(0) = "Discover"
            creditCards(1) = "Visa"
            creditCards(2) = "Master Card"
        Dim creditCardAPRs(MAX_SIZE) As Double
            creditCardAPRs(0) = 12.99
            creditCardAPRs(1) = 7.5
            creditCardAPRs(2) = 18.9
        Dim creditCardBalances(MAX_SIZE) As Double
            creditCardBalances(0) = 300
            creditCardBalances(1) = 400
            creditCardBalances(2) = 500
        Dim myInput As String
        Dim optionNum As String
        Dim tempBalances As Double
        Dim monthlyRate As Double
        Dim numberofDays As Integer
        Dim monthlyBal As Double


        DisplayCreditCards(creditCards, creditCardAPRs, creditCardBalances)

        System.Console.WriteLine("Would you like to adjust the order of the Credit Card?")
        System.Console.WriteLine()
        System.Console.WriteLine("If Yes, type 'Y' --------------------- If No, type 'N'")

        myInput = Console.ReadLine()

        If myInput = "Y" Then
            OrderofCreditCards(creditCards, creditCardAPRs, creditCardBalances, MAX_SIZE)
        End If

        System.Console.WriteLine()
        Console.Clear()
        DisplayCreditCards(creditCards, creditCardAPRs, creditCardBalances)
        System.Console.WriteLine()
        DisplayMenu()
        optionNum = Console.ReadLine()
        numberOfDays = 30

        Select Case optionNum
            Case "1"
                For pos = 0 To creditCards.Length - 1
                    tempBalances = creditCardBalances(pos) * numberOfDays / BILLPERIOD
                    monthlyRate = creditCardAPRs(pos) / MONTHSINYEAR
                    monthlyBal = creditCardBalances(pos)
                    While monthlyBal > 0                                

                        monthlyBal = Payments(tempBalances, monthlyRate)
                        System.Console.WriteLine(monthlyBal)
                    End While                   
                Next
            Case "2"
                System.Console.WriteLine("Case 2")
            Case "3"
                System.Console.WriteLine("Case 3")
            Case "4"
                System.Console.WriteLine("Exiting The Program... ")
                Console.Read()
            Case Else
                System.Console.WriteLine("Error: Not a valid option from the menu. ")
                System.Console.WriteLine("Exiting The Program... ")
        End Select
    End Sub
End Module
模块信用卡计算器
子显示信用卡(ByVal cardNames()作为字符串,ByVal cardAPRs()作为双精度,ByVal cardBalances()作为双精度)
Const_SPACE As String=“”
Dim计数为整数=1
System.Console.WriteLine(“信用卡支付订单”)
System.Console.WriteLine(“---------------------------------------”)
对于pos=0到卡名。长度为-1
System.Console.WriteLine(“信用卡”&计数&“:”)
System.Console.WriteLine(_空格和“名称:”&卡名(pos))
系统控制台写入线(_空格和“APRs:&cardAPRs(pos)和“%”)
系统控制台写入线(_空格和“余额:”&卡余额(pos))
System.Console.WriteLine()
计数=计数+1
下一个
端接头
信用卡的子顺序(ByRef cardNames()为字符串,ByRef cardAPRs()为双精度,ByRef cardBalances()为双精度,ByVal SIZE为整数)
将第一个输入设置为字符串
以字符串形式输入
尺寸swapNames(尺寸)为字符串
双色暗棉签(尺寸)
双色暗交换天平(尺寸)
System.Console.WriteLine(“您希望首先支付哪张信用卡?”)
firstInput=Console.ReadLine()
对于pos=0到卡名。长度为-1
如果firstInput=卡名(pos),则
swapNames(0)=卡名(pos)
swapAPRs(0)=卡达普(pos)
交换余额(0)=卡余额(pos)
退出
如果结束
下一个
System.Console.WriteLine(“您希望第二次支付哪张信用卡?”)
secondInput=Console.ReadLine()
对于pos=0到卡名。长度为-1
如果secondInput=cardNames(pos),则
swapNames(1)=卡名(pos)
swapAPRs(1)=卡达普(pos)
交换余额(1)=卡余额(pos)
退出
如果结束
下一个
对于pos=0到卡名。长度为-1
如果卡名(pos)交换名称(0),则
如果卡名(pos)交换名称(1),则
swapNames(2)=卡名(pos)
swapAPRs(2)=卡达普(pos)
交换余额(2)=卡余额(pos)
退出
如果结束
如果结束
下一个
卡片名称=交换名称
cardAPRs=swapAPRs
卡天平=交换天平
端接头
子显示菜单()
System.Console.WriteLine(“信用卡计算器菜单”)
System.Console.WriteLine(“===========================================”)
System.Console.WriteLine(“选项1.显示每次付款所需的付款总数
卡片。”)
System.Console.WriteLine()
System.Console.WriteLine(“选项2.显示支付每张卡的年数或月数。
")
System.Console.WriteLine()
System.Console.WriteLine(“选项3.显示支付每张卡的余额和总金额
支付所有卡的组合。”)
System.Console.WriteLine()
System.Console.WriteLine(“选项4.退出程序”)
System.Console.WriteLine()
System.Console.WriteLine
("=============================================================================")
System.Console.WriteLine(“说明:键入您要选择的选项旁边的数字
执行。”)
端接头
功能付款(ByVal tempBalances为双倍,ByVal monthlyRate为双倍)为双倍
常量ISSUECHARGE为整数=3
Dim AVG每月BAL为双精度
双重利益
双倍小额付款
平均每月余额=临时余额
利息=月利率
平均每月余额=平均每月余额+利息
最低付款额=平均每月余额*发行费用
平均每月余额=平均每月余额-最低付款额
返回平均每月余额
端函数
副标题()
常量最大值大小为整数=2
常量BILLPERIOD为整数=30
常量monthsineyear为整数=12
作为字符串的Dim信用卡(最大大小)
信用卡(0)=“发现”
信用卡(1)=“Visa卡”
信用卡(2)=“万事达卡”
双码信用卡套裙(最大尺寸)
creditCardAPRs(0)=12.99
creditCardAPRs(1)=7.5
creditCardAPRs(2)=18.9
Dim creditCardBalances(最大尺寸)为双倍
信用卡余额(0)=300
信用卡余额(1)=400
信用卡余额(2)=500
将myInput设置为字符串
Dim optionNum作为字符串
双重平衡
月桂酸双酯
Dim numberofDays为整数
暗淡的月饼是双份的
显示信用卡(信用卡、信用卡账户、信用卡余额)
System.Console.WriteLine(“您想调整信用卡的顺序吗?”)
System.Console.WriteLine()
System.Console.WriteLine(“如果是,请键入'Y'--------------如果不是,请键入'N')
myInput=Console.ReadLine()
如果myInput=“Y”,则
信用卡订单(信用卡、信用卡账户、信用卡余额、最大金额)
如果结束
System.Console.WriteLine()
控制台清除()
显示信用卡(信用卡、信用卡账户、信用卡余额)
System.Console.WriteLine()
显示菜单()
optionNum=Console.ReadLine()
numberOfDays=30
选择案例选项num
Sub DisplayMenu()
    System.Console.WriteLine("CREDIT CARD CALCULATOR MENU")
    System.Console.WriteLine("===========================")
    System.Console.WriteLine("OPTION 1. Display Total Number Of Payments Required To Pay Off Each Card. ")
    System.Console.WriteLine()
    System.Console.WriteLine("OPTION 2. Display The Number Of Years, Or Months To Pay Off Each Card. ")
    System.Console.WriteLine()
    System.Console.WriteLine("OPTION 3. Display The Balance To Payoff Each Card and Total Amount To Payoff All Cards Combined. ")
    System.Console.WriteLine()
    System.Console.WriteLine("OPTION 4. Exit The Program. ")
    System.Console.WriteLine()
    System.Console.WriteLine("=============================================================================")
    System.Console.WriteLine("Instructions: Type The Number That Is Next To The Option You Want To Execute. ")
End Sub
'This will give an error
System.Console.WriteLine("OPTION 3. Display The Balance To  Amount To 

Payoff Each Card and Total Payoff All Cards Combined. ")
'This will also give an error
System.Console.WriteLine("OPTION 3. Display The Balance To  Amount To 
Payoff Each Card and Total Payoff All Cards Combined. ")
'This is acceptable
System.Console.WriteLine("OPTION 3. Display The Balance To  Amount To " & _
"Payoff Each Card and Total Payoff All Cards Combined. ")
'This is also acceptable
System.Console.WriteLine("OPTION 3. Display The Balance To  Amount To " & _
"" & _
"Payoff Each Card and Total Payoff All Cards Combined. ")