i am creatign a program to get a duration from the user and the amound per second. it calculates the price per second for a phone call but i have an issue with 2 lines
with this error message "Index and length must refer to a location within the string. Parameter name: length"Code:varSeconds = CType(tbCallLength.Text.Substring(Sep2, 2), Double) and varPence = CType(tbCallPrice.Text.Substring(Sep4, 2), Double)
can u help please, here is the whole of my code
Code:Option Strict On Public Class frmCallCalculator Dim Sep1, Sep2, Sep3, Sep4 As Integer Dim varMinutes, varSeconds As Double Dim varCal1, varCal2 As Double Dim varPounds, varPence As Double Private Sub btnCalculatePrice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculatePrice.Click Call Minutes() Call Seconds() Call Pounds() Call Pence() varCal1 = CType(varSeconds + (varMinutes * 60), Double) varCal2 = varPence + (varPounds * 100) tbAnswer.Text = CType(varCal1 * varCal2, String) End Sub Private Sub Minutes() Sep1 = InStr(1, tbCallLength.Text, ":") Sep1 = Sep1 - 1 varMinutes = CType(tbCallLength.Text.Substring(0, Sep1), Double) End Sub Private Sub Seconds() Sep2 = InStr(1, tbCallLength.Text, ":") Sep2 = Sep2 + 1 varSeconds = CType(tbCallLength.Text.Substring(Sep2, 2), Double) End Sub Private Sub Pounds() Sep3 = InStr(2, tbCallPrice.Text, ".") Sep3 = Sep3 - 1 varPounds = CType(tbCallPrice.Text.Substring(2, Sep3), Double) End Sub Private Sub Pence() Sep4 = InStr(2, tbCallPrice.Text, ".") Sep4 = Sep4 + 1 varPence = CType(tbCallPrice.Text.Substring(Sep4, 2), Double) End Sub End Class




Reply With Quote