P. nganga P. nganga - 1 year ago 98
Vb.net Question

How do I get rid of the error system.null reference exception object reference not set to an instance of an object

I get an error when i read data in a Null or empty cell in a datagridview to enable me send the data to a fiscal printer

Here is the part of the code


ke.PrintRecMessage("ITEM QTY PRICE AMOUNT")


Dim max1 As Integer = Qualitix_POS.Form1.DataGridView1.Rows.Count - 1

For Each row As DataGridViewRow In Qualitix_POS.Form1.DataGridView1.Rows

Quantity:=row.Cells("Column3").Value.ToString.PadRight(4, "0"),
VatInfo:=row.Cells("Column6").Value, UnitPrice:=row.Cells("Column4").Value,


Answer Source

Add a check in the loop

if row <> nothing then
end if

If that doesnt help, we have some wrappers in our code that return empty string if the response is null


Will return the name or "" same for wrapInt etc

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download