我正在尝试制作一个简单的计算器程序,但是当我构建代码时出现错误(BC30737)说“不可访问”主要'在'模块1'中找到了具有适当签名的方法。而且我不知道究竟是什么导致它或如何解决它。
这不是很好的代码,但我只是想知道如何让它工作!
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
感谢您的帮助
答案 0 :(得分:2)
您将Main()
方法的参数列表更改为:
Public Sub Main(needsWeclome) As Boolean
但Main()
预计会有一些固定的参数,你无法改变它们。
如果您不确定如何将其还原为以前的表单,只需创建一个相同类型的临时新项目,并从那里获取Main()
的原始标题。