gpt4 book ai didi

VB.NET 生成错误 BC30737

转载 作者:行者123 更新时间:2023-12-05 05:19:19 30 4
gpt4 key购买 nike

我正在尝试制作一个简单的计算器程序,但是当我构建代码时出现错误 (BC30737) 说“在‘Module1’中找不到具有适当签名的可访问‘Main’方法,我不知道这是怎么回事一直在研究是什么导致它或如何解决它。

这不是很好的代码,但我只是想知道如何让它工作!

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

感谢帮助

最佳答案

原因:

您将 Main() 方法的参数列表更改为:

Public Sub Main(needsWeclome) As Boolean

但是 Main() 应该有一些固定的参数集,你不能改变它们。

修复:

如果您不确定如何将它恢复到以前的形式,只需创建一个相同类型的临时新项目并从那里获取 Main() 的原始 header 。

关于VB.NET 生成错误 BC30737,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46473886/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com