vb.net - VB Error creating the form -


guys! i'm creating vending machine app final project, ran minor issue. when try run following error, error occurred creating form. see exception.innerexception details. error is: object reference not set instance of object. i'm assuming has label.text have converted double because that's when problem arose. if provide me work around appreciated!

public class vendingmachine dim balance double = cdbl(balancelabel.text) 'dim intbalance string = balancelabel.text 'dim balance double = convert.todouble(intbalance)   private sub button1_click(byval sender system.object, byval e system.eventargs) handles depositbutton.click     if nicklebutton.checked = true         balance = +0.05         balancelabel.text = string.format("{0:c}", balance)     end if      if dimebutton.checked = true         balance = +0.1         balancelabel.text = string.format("{0:c}", balance)     end if      if quarterbutton.checked = true         balance = +0.25         balancelabel.text = string.format("{0:c}", balance)     end if      if dollarbutton.checked = true         balance = +1.0         balancelabel.text = string.format("{0:c}", balance)     end if end sub   private sub button2_click(byval sender system.object, byval e system.eventargs) handles refundbutton.click     balance = 0.0     balancelabel.text = string.format("{0:c}", balance)     msgbox("money refunded") end sub  private sub picturebox2_click(byval sender system.object, byval e system.eventargs) handles starburstpicture.click     if balance >= 1.25         balance = balance - 1.25     else         msgbox("you not have enough money purchace item.")     end if end sub  private sub jollyrancherpicture_click(byval sender system.object, byval e system.eventargs) handles jollyrancherpicture.click     if balance >= 1.0         balance = balance - 1.0     else         msgbox("you not have enough money purchace item.")     end if end sub  private sub gummypicture_click(byval sender system.object, byval e system.eventargs) handles gummypicture.click     if balance >= 0.75         balance = balance - 0.75     else         msgbox("you not have enough money purchace item.")     end if end sub  private sub peppermintpicture_click(byval sender system.object, byval e system.eventargs) handles peppermintpicture.click     if balance >= 0.75         balance = balance - 0.75     else         msgbox("you not have enough money purchace item.")     end if end sub  private sub vendingmachine_load(byval sender system.object, byval e system.eventargs) handles mybase.load  end sub 

end class

do not try values controls before it's loaded - declaring variable based on controls property in class scope. declare variable , figure out , when needs set - otherwise it's empty anyway - right?

edit: hans passant said.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -