Visual Basic Programming skilled only?
crazy busy 08 asked:
I am trying to create a visual basics project that calculates the change after the user enters the amount owed. It needs to tell the user what amount in dollars, quarters, dimes, nickels and pennies. I already entered my variables but I am down to the last two lines of code I thought it was me.xchangelabel.text= val(me.xpaidtextbox.text) - val(me.xowestextbox.text) but I have option strict and explicit on ( Ihave to) and its not helping.
please help someone I am so frustrated. Thanks
Pete
Lanzhou China
Related posts:
- Visual Basic Programming Help? Bipul M asked: Does anyone know the code to save...
- Visual Basic Programming Help? michbox asked: okay i created a simple income calculator but...
- I have a question here about Visual Basic programming, hope you guys will answer:? bill asked: I want to create a program (in Standard...
- How to write a program in Visual Basic to add, update, or delete records? Kevin asked: Okay, I’m about stressed to the limits right...
- Help with Programming in Visual Basic.NET? refuse2lose_2006 asked: I have one context menu and in one...
Filed Under Programming & Design |
Tagged With Computer Language, Visual Basic Programming, Visual Basics
Comments
2 Responses to “Visual Basic Programming skilled only?”
Ok. Here is the problem : you are trying to assign the result of a calculation directly to a textbox, which - as you are experiencing - can be problematic.
I would refer you to an answer I gave someone else today about separating out mathematical operations, and string (or text) operations :
Basically, instead of trying to cram this all into one line, do your math first, then assign to a textbox, like so :
Dim result As double
result = val(me.xpaidtextbox.text) - val(me.xowestextbox.text)
…..then,
me.xchangelabel.text = result.ToString()
You need to convert to string, so it can be displayed in the textbox. Actually, I would even create variables to hold the 2 calcs in the ‘val(me.xpaidt..’ statements - but that’s just me.
Good luck.
if you like the 1 liners u can always just do the following:
me.xchangelabel.text= (val(me.xpaidtextbox.text) - val(me.xowestextbox.text)).ToString()
there is really no need to allocate the extra storage for variables you will not use later. You did well trying to do it without storing them in variables. You just need to make them into strings