-
[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?
-
Re: i need help with this program i have no clue what to do
there is a lblcommission, it's right next to lblcom just nothing in the caption because i wanted to keep it blank, also tyvm for the working code i'll be sure and NOT copy/paste in the future
-
Re: i need help with this program i have no clue what to do
Looks like we cross posted examples. I included the Sub to Clear all the TextBoxes, Timeshifter Formats the calulation - so you need to see both I guess :)
-
Re: i need help with this program i have no clue what to do
Well, I guess it's all good then. At least everything works now... :lol:
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Newtonx
i'll be sure and NOT copy/paste in the future
I wouldn't go that far, Control Arrays have a place. An example is if you have tons of TextBoxes and you want common code - say in the ClickEvent. You only have to code it once, and the refernce will be determined by the INDEX.
The only draw back is not being able to uniqly name each TextBox (althoug you can use the .Tag property)
There is a place for Control Arrays, you just havnt found it yet ;)
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Bruce Fox
I wouldn't go that far, Control Arrays have a place. An example is if you have tons of TextBoxes and you want common code - say in the ClickEvent. You only have to code it once, and the refernce will be determined by the INDEX.
The only draw back is not being able to uniqly name each TextBox (althoug you can use the .Tag property)
There is a place for Control Arrays, you just havnt found it yet ;)
yeah i have no clue what a control array is, but hey i'm learning i just need to read more, now how about enableing a command button when another is pressed if succesfully got it to work in the past but forgot how i did it i think it was something like
cmdButton Enabled = True
but i don't remember
-
Re: i need help with this program i have no clue what to do
Your right ;) Set it's .Enabled proporty to True/False as required.
-
Re: i need help with this program i have no clue what to do
VB Code:
Private Sub cmdCalculate_Click(Index As Integer)
lblCommission.Caption = CStr(Val(txtSales.Text) - Val(txtCost.Text) * 0.2)
cmdPrint Enabled = True
End Sub
doesn't work
-
Re: i need help with this program i have no clue what to do
You need to use the proporty of the CommandButton - so a "." is required.
Do you have intellisense on you IDE (the area you type code)?
When you type "cmdPrint." (note the decimal) the intellisense should show you the available proporties etc.
In any event, tou need:
cmdPrint.Enabled = True
-
Re: i need help with this program i have no clue what to do
Do you have intellisense on you IDE (the area you type code)?
no clue what that is, but ty vm
-
Re: i need help with this program i have no clue what to do
Ok, just realised that yor cmdPrint is also part of a Control Array (intellisense still works tho)
Delete the Button, and add a new one.
-
Re: i need help with this program i have no clue what to do
nvm that didn't work either
-
Re: i need help with this program i have no clue what to do
ok will make a new button lol stupid arrays *in this case anyways*
-
Re: i need help with this program i have no clue what to do
ok the enable works but now the "Print Form" won't work
-
1 Attachment(s)
Re: i need help with this program i have no clue what to do
See the attached.
Actually, intellisense works when you type part of the word say "cmdp" and press Ctrl + Space bar and have the word completed
When I type the decimal, the intellisense popup appears.
-
Re: i need help with this program i have no clue what to do
This forum is one of the best places to learn at your own pace. I know I wouldn't be where I'm at right now if not for this place.
Anyway, until you have need for a control array, I'd stay away from copy-pasting anything on your form. Just create a new object and you'll never make an array unless you mess something up pretty badly.
And Intellisense is that fun little box that pops up when you enter an object name and a ".". For instance, on that program, when you type "cmdPrint.", a box should pop up wen you hit the period, and that box lists all the properties that you can change during runtime. Very useful when trying to discover new commands for stuff.
-
Re: i need help with this program i have no clue what to do
And Bruce, you and me seem to be double posting just about everything, except always in a different fashion... Kinda scary...
-
Re: i need help with this program i have no clue what to do
You know what they say; great minds...
-
Re: i need help with this program i have no clue what to do
okay ic about the intellisense now, as for the enable, it works, but when i press print form it gives me another compile error, all i have for code under the print command button is quite simply
Print Form
-
Re: i need help with this program i have no clue what to do
VB Code:
Private Sub cmdPrint_Click()
PrintForm
End Sub
-
Re: i need help with this program i have no clue what to do
Quote:
Originally Posted by Bruce Fox
VB Code:
Private Sub cmdPrint_Click()
PrintForm
End Sub
lol i feel stupid now i put a space