Im having a bit of trouble with a formatting moment.
I followed the example I was given exactly, but am still not finding what makes the specific line come up as an error. The line with the stars is the one I'm having trouble with. It's just coming up with a System.FormatException. Thanks yall!
Here are two lines from the document I'm trying to read when that float.Parse statement isn't running correctly
****QUICK-Stop|Ikura|31|24|
QUICK-Stop|Gorgonzola Telino|12.5|15|****
private void cmboboxlist_SelectedIndexChanged(object sender, EventArgs e)
{
string [] names = new string[10];
float[] subtotals = new float[10];
string [] fields;
int index = 0;
float subtotal;
string frmStr, currentLine;
StreamReader ReportReader = new StreamReader("PurchaseReport.txt");
lstboxdisplay.Items.Clear();
frmStr = "{0,-20}{1,10}{2,10}{3,20:N1}";
while (ReportReader.EndOfStream == false)
{
currentLine = ReportReader.ReadLine();
fields = currentLine.Split('|');
**** subtotal = float.Parse(fields[2]) + float.Parse(fields[3]);
names[index] = fields[0];
subtotals[index] = subtotal;
index = index + 1;
lstboxdisplay.Items.Add(String.Format(frmStr, fields[0], fields[1], fields[2], fields[3], subtotal));
}
What I have tried:
I've tried changing the formats of the outputs, but it just keeps saying they're formatted incorrectly, though, on another document I have as an example, this format works fine.