收到一条消息,指出“选项严格限制不允许从'String'到'Integer'的隐式转换。”

时间:2018-11-28 09:06:56

标签: vb.net visual-studio-2017 syntax-error basic

我是编程领域的新手,但遇到一个错误,但尚未看到,该错误是“严格的选项不允许从'String'到'Integer'的隐式转换。”我逐字逐句地跟着我的教科书,一切似乎都正确,但我仍然收到此消息。如果有人可以帮助我更好地了解发生的事情,将不胜感激。

Private Sub BtnDiveCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDiveCost.Click
    ' This event determines the cost and displays the size of the dive team, the cost, and the lenght of the dive

    Dim intTeamSize As Integer
    Dim blnNumberInTeamIsValid As Boolean = False
    Dim blnDiveIsSelected As Boolean = False
    Dim intDiveChoice As Integer
    Dim strSelectedTeam As String = ""
    Dim intLocationChoice As Integer
    Dim intLength As Integer = 0
    Dim decTotalCost As Decimal

    ' Calls a function to ensure the number of people in the dive team is valid
    blnNumberInTeamIsValid = ValidateNumberInTeam()
    ' Call a function to ensure a scuba dive was selected
    intDiveChoice = ValidateDiveSelection(blnDiveIsSelected, strSelectedTeam) '<-- Error occurs here.

    ' If Number Of people And the dive trip are valid, calculate the cost
    If (blnNumberInTeamIsValid And blnDiveIsSelected) Then
        intTeamSize = Convert.ToInt32(TxtTeam.Text)
        intLocationChoice = CboLocation.SelectedIndex
        Select Case intLocationChoice
            Case 0
                decTotalCost = AustraliaDiveCost(intDiveChoice, intTeamSize, intLength)
            Case 1
                decTotalCost = BelizeDiveCost(intDiveChoice, intTeamSize, intLength)
            Case 2
                decTotalCost = FijiDiveCost(intDiveChoice, intTeamSize, intLength)
        End Select
        ' Display cost of the scuba dive
        LblScubaDive.Text = "Dive: " & strSelectedTeam
        LblCost.Text = "Cost: " & decTotalCost.ToString("C")
        LblLength.Text = "Length: " & intLength.ToString() & "hours"
    End If
End Sub

0 个答案:

没有答案