Robey
01-29-2004, 02:14 PM
I have a form with a button + listbox.
Click the button and it displays the contents of the .dat file in the listbox.
When built: I click the button and recieve the following error message:
"An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format."
Button Private Sub btndisplayfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplayfile.Click
Dim index As Integer
Dim oneproduct As producttype
lstdisplayfile.Items.Clear()
FileOpen(1, filename, OpenMode.Random, , , Len(oneproduct))
For index = 1 To numberofrecords
FileGet(1, oneproduct)
lstdisplayfile.Items.Add(String.Format(myformat, oneproduct.productid, oneproduct.description, Format(oneproduct.price, "currency"), oneproduct.quantityinstock, oneproduct.reorderlevel))
Next index
End Sub
the myformat refers to this:
Dim myformat As String = "{0. -5}{1, -21}{2, -6}{3, -10}{4, -5}"
structure =
Structure producttype
Dim productid As Short
<VBFixedString(18)> Public description As String
Dim quantityinstock As String
Dim price As Decimal
Dim reorderlevel As Short
End Structure
Im fairly new to this & have no idea whats wrong.
Thanks
Click the button and it displays the contents of the .dat file in the listbox.
When built: I click the button and recieve the following error message:
"An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format."
Button Private Sub btndisplayfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndisplayfile.Click
Dim index As Integer
Dim oneproduct As producttype
lstdisplayfile.Items.Clear()
FileOpen(1, filename, OpenMode.Random, , , Len(oneproduct))
For index = 1 To numberofrecords
FileGet(1, oneproduct)
lstdisplayfile.Items.Add(String.Format(myformat, oneproduct.productid, oneproduct.description, Format(oneproduct.price, "currency"), oneproduct.quantityinstock, oneproduct.reorderlevel))
Next index
End Sub
the myformat refers to this:
Dim myformat As String = "{0. -5}{1, -21}{2, -6}{3, -10}{4, -5}"
structure =
Structure producttype
Dim productid As Short
<VBFixedString(18)> Public description As String
Dim quantityinstock As String
Dim price As Decimal
Dim reorderlevel As Short
End Structure
Im fairly new to this & have no idea whats wrong.
Thanks