저는 VIsual Studio 2015를 사용하여 학교 프로젝트를 진행하고 있습니다. 과제는 교통의 3 가지 옵션으로 GUI "통근 계산기"를 만드는 것입니다. 내 교과서의 지침에 따라하지만, 다음과 같은 오류가 발생하고 코드를 작성했습니다10 진수에서 정수로의 변환 오류가 발생했습니다.
"BC30057 Too many arguments to 'Private Function CarFindCost(intCommuteChoice As Integer, intDays As Integer) As Decimal'."
나는 대에 초보자 해요,하지만 난 문제가 내가 변수를 선언하는 방법으로 믿는 오류를 기반으로. 정수를 10 진수로 변환하는 방법을 봤지만 아무 것도 발견하지 못했습니다. 코드는 길지만 FYI로 모두 포함했습니다. 오류는 개인 하위 btnCommute에 있으며 CarFindCost, BusFindCost 및 TrainFindCost의 세 가지 개인 기능에 연결되어있는 것으로 보입니다. 개인 서브 bthCommute의 intLength 변수에 오류가 발생하지 않도록 수정하는 방법은 무엇입니까?
Option Strict On
Public Class frmCommuteCalc
Dim intCommuteChoice As Integer
Dim strSelectedMode As String = ""
Private _strGas As Integer
Private _strMiles As String = "Enter the total miles for a round trip: "
Private _strMilesPerGallon As Double = 2.15
Private _strDailyParking As Decimal = 10
Private _strMonthlyParking As Decimal
Private _strMonthlyUpkeep As Decimal = 112
Private _strRTBusFare As String = "Round trip bus fare is "
Private _strRTTrainFare As String = "Round trip train fare is "
Private _StrDays As String = "Enter the number of days worked per month: "
Private _intTrainFare As Integer
Private Sub frmCommuteCalc_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Threading.Thread.Sleep(5000)
End Sub
Private Sub cboCommuteMethod_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCommuteMethod.SelectedIndexChanged
Dim intCommuteChoice As Integer
intCommuteChoice = cboCommuteMethod.SelectedIndex()
lstCommute.Items.Clear()
Select Case intCommuteChoice
Case 0
Car()
Case 1
Train()
Case 2
Bus()
End Select
lblDays.Visible = True
lblMiles.Visible = True
lblLength.Visible = True
txtDays.Visible = True
'txtMonthlyTotal.Visible = True
End Sub
Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click
Dim intCommuteChoice As Integer
Dim intDaysPerMonth As Integer
Dim decTotalCost As Decimal
Dim intLength As Integer = 0
Dim strSelectedMode As String = ""
Dim blnNumberInDaysIsValid As Boolean = False
Dim blnCommuteMethodIsSelected As Boolean = False
blnNumberInDaysIsValid = ValidateNumberInDays()
intCommuteChoice = ValidateCommuteSelection(blnCommuteMethodIsSelected, strSelectedMode)
If (blnNumberInDaysIsValid And blnCommuteMethodIsSelected) Then
intDaysPerMonth = Convert.ToInt32(txtDays.Text)
intCommuteChoice = cboCommuteMethod.SelectedIndex()
Select Case intCommuteChoice
Case 0
decTotalCost = CarFindCost(intCommuteChoice, intDaysPerMonth, intLength)
Case 1
decTotalCost = BusFindCost(intCommuteChoice, intDaysPerMonth, intLength)
Case 2
decTotalCost = TrainFindCost(intCommuteChoice, intDaysPerMonth, intLength)
End Select
End If
End Sub
Private Function intLength() As Object
Throw New NotImplementedException()
End Function
Function ComputeCommuteCost(ByVal decMiles As Decimal, ByVal decGallons As Decimal) As Decimal
Dim decMilage As Decimal
decMilage = decMiles/decGallons
Return decMilage
End Function
Private Sub Car()
lstCommute.Items.Add(_strMiles)
lstCommute.Items.Add(_strMilesPerGallon)
lstCommute.Items.Add(_StrDays)
lstCommute.Items.Add(_strMonthlyParking)
lstCommute.Items.Add(_strMonthlyUpkeep)
End Sub
Private Sub Bus()
lstCommute.Items.Add(_strRTBusFare)
lstCommute.Items.Add(_StrDays)
End Sub
Private Sub Train()
lstCommute.Items.Add(_StrDays)
lstCommute.Items.Add(_strRTTrainFare)
End Sub
Private Function ValidateNumberInDays() As Boolean
Dim intDays As Integer
Dim blnValidityCheck As Boolean = False
Dim strNumberInDaysMessage As String = "Please enter the No. of days per month you will be commuting "
Dim strMessageBoxTitle As String = "Error"
Try
intDays = Convert.ToInt32(txtDays.Text)
If intDays >= 1 And intDays <= 21 Then
blnValidityCheck = True
Else
MsgBox(strNumberInDaysMessage, , strMessageBoxTitle)
txtDays.Focus()
txtDays.Clear()
End If
Catch Exception As FormatException
MsgBox(strNumberInDaysMessage, , strMessageBoxTitle)
txtDays.Focus()
txtDays.Clear()
Catch Exception As OverflowException
MsgBox(strNumberInDaysMessage, , strMessageBoxTitle)
txtDays.Focus()
txtDays.Clear()
Catch Exception As SystemException
MsgBox(strNumberInDaysMessage, , strMessageBoxTitle)
txtDays.Focus()
txtDays.Clear()
End Try
Return blnValidityCheck
End Function
Private Function ValidateCommuteSelection(ByRef blnDays As Boolean, ByRef strDays As String) As Integer
Dim intCommuteChoice As Integer
Try
intCommuteChoice = Convert.ToInt32(lstCommute.SelectedIndex)
strDays = lstCommute.SelectedItem.ToString()
blnDays = True
Catch Exception As SystemException
MsgBox("Select a commute mode", , "Error")
blnDays = False
End Try
Return intCommuteChoice
End Function
Private Function CarFindCost(ByVal intCommuteChoice As Integer, ByVal intDays As Integer) As Decimal
Dim decDaysPerMonth As Decimal
Dim decMiles As Decimal
Dim decMilesPerGallon As Decimal = 2
Dim decGasTotal As Decimal
Dim decDailyParking As Decimal = 10
Dim decMonthlyParking As Decimal
Dim decMonthlyUpkeep As Decimal = 112
Dim decFinalCost As Decimal
Dim intLength As Integer = 0
decMiles = Convert.ToDecimal(txtMiles.Text)
decMilesPerGallon = Convert.ToDecimal(txtGallons.Text)
decGasTotal = decMilesPerGallon * decMiles
decMonthlyParking = Convert.ToDecimal(lblLength.Text)
decMonthlyParking = decDailyParking * decDaysPerMonth
decFinalCost = Convert.ToDecimal(lblLength.Text)
decFinalCost = decGasTotal + decMonthlyUpkeep + decMonthlyParking
Return decFinalCost
End Function
Private Function BusFindCost(ByVal intCommuteChoice As Integer, ByVal intDays As Integer) As Decimal
Dim intLength As Integer = 0
Dim decDaysPerMonth As Decimal
Dim decBusFarePerDay As Decimal = 4
Dim decFinalCost As Decimal
decBusFarePerDay = Convert.ToDecimal(txtMonthlyTotal)
decFinalCost = decBusFarePerDay * decDaysPerMonth
Return decFinalCost
End Function
Private Function TrainFindCost(ByVal intCommuteChoice As Integer, ByVal intDays As Integer) As Decimal
Dim intLength As Integer = 0
Dim decDaysPerMonth As Decimal
Dim decTrainFarePerDay As Decimal = 18
Dim decFinalCost As Decimal
decTrainFarePerDay = Convert.ToDecimal(txtMonthlyTotal)
decFinalCost = Convert.ToDecimal(txtMonthlyTotal)
decFinalCost = decDaysPerMonth * decTrainFarePerDay
Return decFinalCost
End Function
End Class
215 행의 코드를 게시했습니다. 당신은 1에서 컴파일러 오류가 발생했습니다. 그리고 정수로 10 진수 변환 오류가 아닙니다. – abatishchev
당신은 3 개의 인자 ('intLength'는 세번째 인자)를 2 개의 인자만을 기대하는 함수에 전달합니다. – Ryan
@abatishchev. 말하기에 도움이되는 것이 없다면 왜 댓글을 쓰지요. 저는이 일에 익숙하지 않고 도움을 요청하면서 비판 대신 약간의 동정심이 좋았을 것입니다. 스택 오버플로에이 옵션이 있으면 나를 차단하십시오. – lorac1969