vb.net - Visual Studio Button code error -
this first time using visual studio , i'm running error tax calulator application. problem visual studio saying multiplication line using "*" , "+" can not done due variables being text boxes. question community, should change text box else? or in code did mess up.
public class form1 private sub btncalc_click(byval sender system.object, byval e system.eventargs) handles btncalc.click if (isnumeric(txtsale) , isnumeric(txtsalestaxrate)) lbltax = txtsale * txtsalestaxrate lbltotal = txtsale + lbltax else msgbox("please enter valid numbers, thank you!") end if end sub end class if need me give full layout of application, ask.
i can see multiple problems in code. explain how "vs" works.the textboxes you've made controls.
you can't take value simple.they have many property , 1 of them .text allows take value inside them.
another mistake you've made you've tried textboxes.what type in textboxes ..well text. program can't tell if value inside number or text. must convert value in number using cint.
so you're code this:
public class form1 private sub btncalc_click(byval sender system.object, byval e system.eventargs) handles btncalc.click if (isnumeric(txtsale.text) , isnumeric(txtsalestaxrate.text)) lbltax.text= cint(txtsale.text) * cint(txtsalestaxrate.text) lbltotal.text= cint(txtsale.text) + cint(lbltax.text) else msgbox("please enter valid numbers, thank you!") end if end sub end class what cint convert every type of data integer. .text property lets set value of control (in our case label caption)
Comments
Post a Comment