.net - Null exception was unhandled? -
i working on assignment friend. asked on how loop , gave me code part. copied , pasted vb. works him everytime try debug keep getting sign "null exception unhandled". not 1 one line. fist starts on lstinvoice.items.clear() if delete that, goes through lines. going on? used lstinvoice.items.clear() before on other assignments , never had problem before. here code:
private sub btnstraight_click(byval sender system.object, byval e system.eventargs) handles btnstraight.click dim cost double cost = txtcost.text dim salvage_value double salvage_value = 0 dim life double life = txtlife.text dim depreciation double depreciation = (cost / life) dim c integer, integer, x integer, y integer, z integer c = cint(cdbl(txtyear.text)) = cint(txtlife.text) x = cint(txtcost.text) y = cint(cdbl(x) / i) z = x - y lstinvoice.items.clear() lstinvoice.items.add("description: " & "" & txtdescription.text) lstinvoice.items.add("year of purchase: " & txtyear.text) lstinvoice.items.add("cost: " & formatcurrency(txtcost.text)) lstinvoice.items.add("estimated life:" & txtlife.text) lstinvoice.items.add("method of depresciation: straight-line method") lstinvoice.items.add("") lstinvoice.items.add("value beginning of " & c & ": " & formatcurrency(cint(txtcost.text))) lstinvoice.items.add("amount of depreciation accruing: " & c & ": " & formatcurrency(y)) lstinvoice.items.add("total depreaciation @ end of " & c & ": " & formatcurrency(z)) lstinvoice.items.add("") c = c + 1 while (x > 0) y = cint(cdbl(x) / i) z = x - y x = z lstinvoice.items.add("value beginning of " & c & ": " & formatcurrency(x)) lstinvoice.items.add("amount of depreciation accruing: " & c & ": " & formatcurrency(y)) lstinvoice.items.add("total depreaciation @ end of " & c & ": " & formatcurrency(z)) lstinvoice.items.add("") = - 1 c = c + 1 loop
you haven't capitalized properly, should this:
lstinvoice.items.clear()
notice capital , c.
Comments
Post a Comment