简体   繁体   English

VB.NET 构建错误 BC30737

[英]VB.NET Build Error BC30737

I am trying to make a simple calculator program but when I build the code an error come up (BC30737) saying 'No accessible 'Main' method with and appropriate signature was found in 'Module1' and I have no clue what so ever on what is causing it or how to fix it.我正在尝试制作一个简单的计算器程序,但是当我构建代码时出现错误(BC30737)说“没有可访问的‘Main’方法和适当的签名在‘Module1’中找到,我不知道什么是什么导致它或如何修复它。

It's not very good code but I was just wondering how to make it work!这不是很好的代码,但我只是想知道如何使它工作!

Module Module1

    Public Sub Main(needsWeclome As Boolean)

        'See's if the user needs the copyright notice or not.
        If needsWeclome = True Then

            'Says welcome back to the user.
            Console.WriteLine("Welcome Back")
            Console.WriteLine(" ")

            'Skips copyright notice.
            GoTo Restart

        End If

        Call Introduction()

Restart:
        Call MethordOfCalc()
        Call PlayAgain()

        Console.ReadLine()

    End Sub

    Sub Introduction()

        'Legal stuff!
        Console.WriteLine("The Calaculator!")
        Console.WriteLine("(C) Copyright James Robinson 2017")
        Console.WriteLine("All rights reserved.")

        'Introduction and asking the user for there prefered method of calculation.
        Console.WriteLine("What is your prefered methord of the calcultions!")

    End Sub

    Sub MethordOfCalc()

Options:
        'Gives the user there of options.
        Console.WriteLine("Chose from the following below:")
        Console.WriteLine("1. Add       5. Powers")
        Console.WriteLine("2. Subtract  6. Square Root")
        Console.WriteLine("3. Multiply  7. Modulous")                       'Check Spelling of 7.
        Console.WriteLine("4. Divide    8. W.I.P xRoot")
        Console.WriteLine()

        'Puts the choice into a varible and dicides what sub to hand it over to 
        'the correct sub for the opperation.
        Dim choice As Integer = Console.ReadLine()

        If choice = 1 Then
            Call Add()
        ElseIf choice = 2 Then
            Call Subtract()
        ElseIf choice = 3 Then
            Call Muliply()
        ElseIf choice = 4 Then
            Call Divide()
        ElseIf choice = 5 Then
            Call Powers()
        ElseIf choice = 6 Then
            Call SquareRoot()
        ElseIf choice = 7 Then
            Call Modu()
        ElseIf choice = 8 Then
            Call xRoot()
        Else Console.WriteLine("Please enter a valid number")
            GoTo Options

        End If

    End Sub

    Sub Add()

        Console.Write("Enter your first number to add: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the second number to add: ")
        Dim num2 As Decimal = Console.ReadLine()
        Dim ans As Decimal = num1 + num2

    End Sub

    Sub Subtract()

        Console.Write("Enter your first number: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the second number: ")
        Dim num2 As Decimal = Console.ReadLine()
        Dim ans As Decimal = num1 - num2

    End Sub

    Sub Muliply()

        Console.Write("Enter your first number to multiply: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the second number to multiply: ")
        Dim num2 As Decimal = Console.ReadLine()
        Dim ans As Decimal = num1 * num2

    End Sub

    Sub Divide()

        Console.Write("Enter your first number to divide: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the second number to divide: ")
        Dim num2 As Decimal = Console.ReadLine()
        Dim ans As Decimal = num1 / num2

    End Sub

    Sub Powers()

        Console.Write("Enter your the numbered being powered!: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the number to power " & num1 & " by: ")
        Dim num2 As Decimal = Console.ReadLine()
        Console.WriteLine(num1 ^ num2)

    End Sub

    Sub SquareRoot()

        Console.Write("Enter the number that you want the square root of: ")
        Dim num1 As Double = Console.ReadLine()
        Dim ans As Decimal = Math.Sqrt(ans)

    End Sub

    Sub Modu()

        Console.Write("Enter your first number to divide: ")
        Dim num1 As Decimal = Console.ReadLine()
        Console.Write("Enter the second number to divide: ")
        Dim num2 As Decimal = Console.ReadLine()
        Dim ans As Decimal = num1 Mod num2

    End Sub

    Sub xRoot()

        Console.WriteLine("xRoot is still in development")
        Console.WriteLine(" ")
    End Sub

    Sub PlayAgain()

        Call Main(1)

    End Sub

End Module

Thanks for the help谢谢您的帮助

Cause:原因:

You changed the parameters list of the Main() method into:您将Main()方法的参数列表更改为:

Public Sub Main(needsWeclome) As Boolean

But Main() is expected to have certain fixed set of parameters, you cannot change them.但是Main()预计具有某些固定的参数集,您无法更改它们。

Fix:使固定:

If you are not sure how to revert it to previous form, just create a temporary new project of the same type and take original header of Main() from there.如果您不确定如何将其恢复为以前的形式,只需创建一个相同类型的临时新项目并从那里获取Main()原始标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM