0

Hello, I've been trying to create a function to calculate and return the total payment. RadioDay is a radio button with value of 7 while RadioHour is 70. Somehow I am getting InvalidCastException "Conversion from string "" to type 'Integer' is not valid." from the part where I want to convert user inputs from textbox "txtByHour" and "txtByDay" into integer value. Any help is greatly appreciated.

Function calcRate() As Integer 'calculate and return total payment for car
        Dim total, byHour, byDay As Integer

        byHour = CInt(txtByHour.Text)
        byDay = CInt(txtByDay.Text)

        If byHour > 24 Then 'making sure the user does not input more than 24 hours
            MessageBox.Show("Please put a number between 1 to 24")
        End If

        If RadioDay.Checked Then

            total = byHour * 7
        ElseIf RadioHour.Checked Then

            total = byDay * 70
        End If


        Return total


    End Function
2
Contributors
4
Replies
27
Views
3 Years
Discussion Span
Last Post by Pickletronic
0

Thank you very much it's working perfectly now

Edited by Pickletronic: Found a solution

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.