RobJanine
asked on
Format Exception was Unhandled
I am getting the following error in the below code
Format Exception was unhandled
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
The error is in the line of code starting lstOutput in Sub FinancialCharges.
Can someone please tell me what I am doing wrong?
Public Class frmCreditCardAccounts
Private Sub btnDisplaySummary_Click(By Val sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplaySummary.Click
Dim AccountNumber As String, PastDueAmt, Payments, Purchases As Double
Dim sr As IO.StreamReader = IO.File.OpenText("3-PP-3.T XT")
Dim fmtStr As String = "{0,-30}{1,8} {2,8} {3,8} {4,8} {5,8}"
lstOutput.Items.Clear()
lstOutput.Items.Add(String .Format(fm tStr, "Account Number", "Past Due Amount", "Payments", "Purchases", "Financial Charges", "Current Amount Due"))
AccountNumber = sr.ReadLine
PastDueAmt = CDbl(sr.ReadLine)
Payments = CDbl(sr.ReadLine)
Purchases = CDbl(sr.ReadLine)
CalcFinancialCharges(Accou ntNumber, PastDueAmt, Payments, Purchases)
AccountNumber = sr.ReadLine
PastDueAmt = CDbl(sr.ReadLine)
Payments = CDbl(sr.ReadLine)
Purchases = CDbl(sr.ReadLine)
CalcFinancialCharges(Accou ntNumber, PastDueAmt, Payments, Purchases)
sr.Close()
End Sub
Sub CalcFinancialCharges(ByVal AccountNumber As String, ByVal PastDueAmt As Double, ByVal Payments As Double, ByVal Purchases As Double)
Dim FinancialCharges As Integer
Dim fmtStr As String = "{0,-30}{1,4} {2,4} {3,8} {4,8} {5,8}"
FinancialCharges = (PastDueAmt - Payments) * 0.015
lstOutput.Items.Add(String .Format(fm tStr, AccountNumber, PastDueAmt, Payments, Purchases, FormatCurrency(FinancialCh arges, 2)))
End Sub
Sub CalcCurrentAmtDue(ByVal AccountNumber As String, ByVal PastDueAmt As Double, ByVal Payments As Double, ByVal Purchases As Double, ByVal FinancialCharges As Double)
Dim CurrentAmtDue As Integer
Dim fmtStr As String = "{0,-30}{1,8} {2,8} {3,8} {4,8} {5,8}"
CurrentAmtDue = PastDueAmt - Payments + Purchases + FinancialCharges
lstOutput.Items.Add(String .Format(fm tStr, AccountNumber, PastDueAmt, Payments, Purchases, FormatCurrency(FinancialCh arges, 2)))
End Sub
End Class
Format Exception was unhandled
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
The error is in the line of code starting lstOutput in Sub FinancialCharges.
Can someone please tell me what I am doing wrong?
Public Class frmCreditCardAccounts
Private Sub btnDisplaySummary_Click(By
Dim AccountNumber As String, PastDueAmt, Payments, Purchases As Double
Dim sr As IO.StreamReader = IO.File.OpenText("3-PP-3.T
Dim fmtStr As String = "{0,-30}{1,8} {2,8} {3,8} {4,8} {5,8}"
lstOutput.Items.Clear()
lstOutput.Items.Add(String
AccountNumber = sr.ReadLine
PastDueAmt = CDbl(sr.ReadLine)
Payments = CDbl(sr.ReadLine)
Purchases = CDbl(sr.ReadLine)
CalcFinancialCharges(Accou
AccountNumber = sr.ReadLine
PastDueAmt = CDbl(sr.ReadLine)
Payments = CDbl(sr.ReadLine)
Purchases = CDbl(sr.ReadLine)
CalcFinancialCharges(Accou
sr.Close()
End Sub
Sub CalcFinancialCharges(ByVal
Dim FinancialCharges As Integer
Dim fmtStr As String = "{0,-30}{1,4} {2,4} {3,8} {4,8} {5,8}"
FinancialCharges = (PastDueAmt - Payments) * 0.015
lstOutput.Items.Add(String
End Sub
Sub CalcCurrentAmtDue(ByVal AccountNumber As String, ByVal PastDueAmt As Double, ByVal Payments As Double, ByVal Purchases As Double, ByVal FinancialCharges As Double)
Dim CurrentAmtDue As Integer
Dim fmtStr As String = "{0,-30}{1,8} {2,8} {3,8} {4,8} {5,8}"
CurrentAmtDue = PastDueAmt - Payments + Purchases + FinancialCharges
lstOutput.Items.Add(String
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sub CalcCurrentAmtDue(ByVal AccountNumber As String, ByVal PastDueAmt As Double, ByVal Payments As Double, ByVal Purchases As Double, ByVal FinancialCharges As Double)
Dim CurrentAmtDue As Integer
Dim fmtStr As String = "{0,-30}{1,8} {2,8} {3,8} {4,8} {5,8}"
CurrentAmtDue = PastDueAmt - Payments + Purchases + FinancialCharges
lstOutput.Items.Add(String
End Sub