BC30420' Sub Main'在Windows窗体应用程序中找不到错误

时间:2017-03-27 13:49:12

标签: vb.net

我已经创建了一个Windows窗体应用程序。我的理解是,您不必在Windows窗体应用程序中拥有Sub Main()。但是,当我构建项目时,我收到此错误:

BC30420 'Sub Main' was not found in 'LoanCalculator.Module1'.

首先,我不知道为什么它会说&LoanCalculator.Module1'。我的表单和我的类都被命名为LoanCalculator.vb。当我开始这个项目时,我开始在原始模块中编写代码。然后我添加了一个模块,命名为' LoanCalculator'并将我编写的代码移动到该模块并在那里完成。我删除了原始模块。现在它构建正常,除了这一个错误。这是我的代码:

Imports System.Windows.Forms

Public Class LoanCalculator

    Private Sub Calculate()
        Dim str As String
        Dim intLoanAmt As Integer
        Dim intDown As Integer
        Dim intFees As Integer
        Dim intBalance As Integer
        Dim dblIntsRate As Single
        Dim intLoanTerm As Integer
        Dim sngInterestPaid As Single
        Dim intTermMonths As Integer
        Dim dblMonthlyPmt As Integer
        Dim intTotalPaid As Integer
        Dim dblYon As Double
        Dim dblXon As Double
        Dim dblZon As Double

        If Not CheckInput() Then
            Return
        End If

        intLoanAmt = Convert.ToInt32(txtLoan.Text)
        intFees = Convert.ToInt32(txtFees.Text)
        intDown = Convert.ToInt32(txtDown.Text)
        intBalance = Convert.ToInt32(intLoanAmt - intDown + intFees)
        intLoanTerm = Convert.ToInt32(txtTerm.Text)
        dblIntsRate = Convert.ToDouble(txtTerm.Text)
        intTermMonths = intLoanTerm * 12
        dblYon = dblIntsRate / 1200
        dblXon = dblYon + 1
        dblZon = Math.Pow(dblXon, intTermMonths) - 1
        dblMonthlyPmt = (dblYon + (dblYon / dblZon)) * intBalance
        intTotalPaid = dblMonthlyPmt * intTermMonths
        sngInterestPaid = intTotalPaid - intBalance
        str = "Loan balance =" & Space(11) & intBalance.ToString & vbCrLf
        str = str & "Loan Term =" & Space(16) & intLoanTerm.ToString & " years" & vbCrLf
        str = str & "Interest paid =" & Space(17) & intTotalPaid.ToString & vbCrLf
        str = str & "Monthly payment =" & Space(5) & dblMonthlyPmt.ToString
        lblResults.Text = str

    End Sub

    Private Function CheckInput() As Boolean
        Dim strErr As String = ""

        If txtLoan.Text.Length = 0 Then
            strErr = "Enter loan amount" & vbCrLf
        End If

        If txtDown.Text.Length = 0 Then
            strErr = strErr & "Enter down payment" & vbCrLf
        End If

        If txtInterest.Text.Length = 0 Then
            strErr = strErr & "Enter interest rate" & vbCrLf
        End If

        If txtFees.Text.Length = 0 Then
            strErr = strErr & "Enter fees" & vbCrLf
        End If

        If txtTerm.Text.Length = 0 Then
            strErr = strErr & "Enter loan term" & vbCrLf
        End If

        If strErr.Length > 0 Then
            MessageBox.Show(strErr)
            Return False
        Else
            Return True
        End If
    End Function

End Class

我该如何解决这个问题?

0 个答案:

没有答案