Posted by Reese on Friday, February 25, 2011 at 3:52pm.
The logic looks OK, but incomplete.
It is good practice to use try/catch blocks for user entered values. You need to elaborate on that, i.e. error messages, try again, etc.
There is one little point you can improve on: you have defined the commission rate in two separate places. In normal programming, this is not a good idea. If tomorrow the rate changes, you will need to change it in two different places. What if your assistant programmer forgot or did not know that it is defined in two places?
So try to define "global" constants in one place, and make it accessible to everyone.
I also have a question: what is the commission structure? Most of the time, the commission depends only on the selling price. Here you enter the cost AND the selling price. Is the cost used at all?
First off, Thank you MathMate.
As for it being incomplete, I'm in the process of writing it, I've just run into a wall, really.
The commission structure is Commission = Commission rate * (Sales price - Cost Value)
I was told by the professor to use one of the hands-on exercises as a loose guideline, and I'm not one for thinking too freely when it comes to code, so I ended up copying quite a bit of it over, tweaking it for the names of my TextBoxes. I've been trying to find a guideline for this specific problem, but have had no luck.
This is an online class, and I'm really not learning much from just reading the book, so any advice would be helpful.
Just like we cannot learn to drive a car if we don't have one, do you happen to have VB installed on your computer?
One of the few advantages of a learner-programmer is you have unlimited number of tries, and eventually you'll get somewhere. Evidently you cannot try blindly, but much of the learning is trying things out. You try, the VB compiler catches!
If you have your hands on the VB compiler, you will find that much of the mundane stuff is automated, like the routines for the text-boxes, etc. You only have to fill in the "meat", which is what you're after.
In any case, I suppose you will need two textboxes to enter the selling price and the cost, a button to calculate, and a textbox to display the results. All this can be done by drag-and-drop on the GUI (graphics user interface) of VB. You only have to tweak the error detecting procedures.
Your first priority is to make something that compiles, as simple as you wish, even if it does nothing.
Then you can test your own code, incrementally, so that if there is an error, you know exactly where it happens.
If it does not compile, and you have difficulty finding the problem, post.
Related Questions
Programming - Here is the question that I need help to write the code for the ...
Ms Visio - 2. Construct a data dictionary and draw a hierarchy chart and ...
visual basic - in visual basic, notes in a program which explain what the ...
Programming - Read two numbers from the keyboard Display the menu options as ...
Programming (Visual Basic) - Im seem to be having trouble with this Exercise. ...
Visual Basic - Help with code Enter 10000 for total sales Base pay cont $900. ...
PROGRAMMING - PLS, I NEED TO BE GUIDED ON HOW TO WRITE A SIMPLE PROGRAM IN BASIC...
visual basic - in visual basic, a routine that puts a series of strings or ...
Programming - I need your help to write a program using visual basic 2010 for ...
visual basic - notes in a program which explain what the program is doing are ...
For Further Reading