-
[RESOLVED] i need help with this program i have no clue what to do
i need to have this done in the next few hours but i have no idea how to do all these dam functions...here is what i need done
:confused:
When a commission is given for a salesperson his or her percent of total sales should also be given
add a summary command button. when it is clicked, total sales, total profit, and average commission will be placed on the form. the calculate command button should be the default button. the clear command button should be the cancel button. make sure to document the project with remark statements. use the naming rules and conventions studied
Put to use the following items:
tool tips
access keys
enabled property
tab order and setting focus during execution
formatting functions
accumulators
VB Auto Center
Salespeople for the used are compensated using a commission system. the commission is based on the costs incured for the vehicle
Commission =
Commission rate X (Sales price - Cost value)
the screen will allow the user to enter the salesperson's name, the selling price of the vehicle, and the cost of the vehicle. Use a constant of 20 percent for the commission rate.
The Calculate command button will determine the commission earned by the salesperson; the Clear button will clear the text boxes. a Print Form button will be available ONLY after the calculation has been made. it will be disabled untill the Calculate button has been pressed the first time. When the Clear button is pressed, the Print Form button will become disabled.
-
Re: i need help with this program i have no clue what to do
Sorry we don't do people's homework on this forum.
I am sure you had more than just a "few hours" to do this project, I don't know why you waited until the last minute, however that is neither here nor there. We just don't do homework for people.
-
Re: i need help with this program i have no clue what to do
let me be more specific on what i need help with, i need the syntax for a command button, that when i press it the contents of a text box - the contents of another text box is multiplied by 20, and that is put into a lbl box
-
Re: i need help with this program i have no clue what to do
what do you have done so far? please post the code you have come up with, and I am sure people on here will be more than happy to help you.
The "problem", if you want to call it that, is people on here LOVE to help, but they don't like to do all the work for you. If you show effort being put forward, you will likely get the help you need.
-
Re: i need help with this program i have no clue what to do
i have the layout all my command buttons are down i have the text boxes made lbl box is made but i don't know the syntax to put on cmdCalculate so it will do lblCommission.Caption = 20% * (txtsales.Text - txtCost.txt) whats the syntax to get it to do that? is what i want to know, got the print form button working not sure about the clear button it's supposed to clear the values of the text boxes...but idk how i'll check up on that later....thats all i really don't understand for now
Edit: also clear is set as cancel button and calculate is set as default button
-
Re: i need help with this program i have no clue what to do
-
Re: i need help with this program i have no clue what to do
ok, then you are in the wrong forum. I will move this for you.
-
Re: i need help with this program i have no clue what to do
In the form view, double click your command button to create the Command_Click event. Inside that sub, put the code for your computation. Easy as that.
-
Re: i need help with this program i have no clue what to do
Untested:
VB Code:
Option Explicit
Private Sub cmdCalculate_Click()
lblCommission.Caption = CStr((txtsales.Text - txtCost.Text) * 0.2)
End Sub
-
Re: i need help with this program i have no clue what to do
yes but what is the syntax for the code i don't know the formatting function i have to put with it and sorry for the wrong forum, nice 127.0.0.1 ip no place like home definatly true
-
Re: i need help with this program i have no clue what to do
Why set it as a string? A label's Caption property understands numbers perfectly well, and you might want to keep it as a number in case you need to use it later.
-
Re: i need help with this program i have no clue what to do
You may also want to add some error handling incase someone enters values that are not valid to compute... like entering letters where they should enter numbers..
-
Re: i need help with this program i have no clue what to do
If the TextBox's are NOT in a Control Array, then:
VB Code:
Option Explicit
Private Sub cmdClear_Click()
Dim ctl As Control
For Each ctl In Controls
If TypeOf ctl Is TextBox Then ctl.Text = vbNullString
Next
End Sub
-
Re: i need help with this program i have no clue what to do
Here:
VB Code:
Private Sub cmdCalculate_Click()
lblCommision.Caption = Round(((CDbl(txtsales.Text) - CDbl(txtCost.Text)) * 0.2), 2)
End Sub
That will calculate and round to two places, to keep it as a currency value.
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Bruce Fox
Untested:
VB Code:
Option Explicit
Private Sub cmdCalculate_Click()
lblCommission.Caption = CStr((txtsales.Text - txtCost.Text) * 0.2)
End Sub
it doesn't like the .Text on either sales or cost
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by kleinma
You may also want to add some error handling incase someone enters values that are not valid to compute... like entering letters where they should enter numbers..
Easy solution.
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by timeshifter
Here:
VB Code:
Private Sub cmdCalculate_Click()
lblCommision.Caption = Round(((txtsales.Text - txtCost.Text) * 0.2), 2)
End Sub
That will calculate and round to two places, to keep it as a currency value.
also doesn't like the .Text on either, i am so confused
-
Re: i need help with this program i have no clue what to do
See my previous post. Just appended it to solve that problem.
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by timeshifter
Why set it as a string? A label's Caption property understands numbers perfectly well
Because the Caption data type is a String. Casting it to a String is the correct way to do it.
TextBoxes default is .Text and you dont have to use it, but I always explicitly use Text1.Text, as in VB.Net there is no default - just good practice :)
-
Re: i need help with this program i have no clue what to do
True, but the value will automatically get passed as a string when it's set as the Caption or Text property.
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Bruce Fox
Because the Caption data type is a String. Casting it to a String is the correct way to do it.
TextBoxes default is .Text and you dont have to use it, but I always explicitly use Text1.Text, as in VB.Net there is no default - just good practice :)
especially if you plan to move to .NET where they have implement strict casting so you can add two numeric strings together without first casting them as numbers.
Sure you can turn option strict off, but I wouldn't recommend it.
-
Re: i need help with this program i have no clue what to do
Is txtsales a Variable, or a TextBox?
-
Re: i need help with this program i have no clue what to do
Private Sub cmdCalculate_Click(Index As Integer)
lblCommision.Caption = Round(((CDbl(txtSales.Text) - CDbl(txtCost.Text)) * 0.2), 2)
End Sub
it highlights the Private Sub cmdCalculate_Click(Index As Integer) in yellow and the .Text in blue still an error..should i create a new project and try it?
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Bruce Fox
Is txtsales a Variable, or a TextBox?
text box
-
Re: i need help with this program i have no clue what to do
Are the TextBox's on the same Form as the CommandButton?
If so, what is the Error?
-
Re: i need help with this program i have no clue what to do
i remade it just putting a txtCost and txtSales as text boxes, and cmdCalculate as the command button and lblCommission as the label button, still nogo
-
Re: i need help with this program i have no clue what to do
Zip up your project files and post them up so we can see what's going on. There are any number of things that could be throwing your program off.
-
Re: i need help with this program i have no clue what to do
Compile Error
Method or data not found!
thats what i get when it highlights when i try to execute the calculate button
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by timeshifter
Zip up your project files and post them up so we can see what's going on. There are any number of things that could be throwing your program off.
how do i post a file?
-
Re: i need help with this program i have no clue what to do
Hit the Manage Attachments button underneath the Reply box (Go Advanced, can't do it with a quick reply), find the target file, and hit Upload.
-
1 Attachment(s)
Re: i need help with this program i have no clue what to do
-
Re: i need help with this program i have no clue what to do
File missing.
Attach the .frm(Form) file (no need to zip it).
-
Re: i need help with this program i have no clue what to do
The .vbp is just a database of what the project contains. We need the forms, modules, etc. that actually comprise the project.
-
1 Attachment(s)
Re: i need help with this program i have no clue what to do
-
Re: i need help with this program i have no clue what to do
Those TextBoxes are in a Contrrol Array and require a Index! thats all :)
-
Re: i need help with this program i have no clue what to do
You're right, you did need help... and there's a good reason it won't work.
You have txtSales and txtCost as members of a control array. I'm guessing you made one text box, then copy-pasted the others to keep the size. Unfortunately, you kept the name, which made them an array, then you changed the name but they kept their status as members of an array. Delete them, make new text boxes, and don't copy-paste them. Just resize them all to where you need them, and give them the right names.
Secondly, you don't have a lblCommision. You have a lblCom. If you try to use a name that's not assigned to an object, you'll get errors since the object doesn't exist.
-
Re: i need help with this program i have no clue what to do
Control Arrays are handy, however in this case you may want to add a new set of 3 TextBox's
correctly named, but dont select yes when prompted to make a Control Array when 'pasting' the TextBox's.
-
Re: i need help with this program i have no clue what to do
And if you want percentages, it needs to be multiplied by .2 instead of 20. See this form. I think it's what you're looking for.
-
1 Attachment(s)
Re: i need help with this program i have no clue what to do
-
Re: i need help with this program i have no clue what to do
Is there an echo in here?