so you mean i don't have to change anything except for the 300 and 399
But just leave the 200 alone :confused:
Printable View
so you mean i don't have to change anything except for the 300 and 399
But just leave the 200 alone :confused:
Is the 200 doing what you need it to do?Quote:
Originally Posted by Franklin67
yes i have to use the 200 -399 But Now confused
If the price is the same for 200-399, then you don't have to insert another case statement, you can just change your code from 200-299 to 200-399 and it will work fine.
Jee Thanks Now I got it almost
'to calculate totals use this:VB Code:
Private Sub cmdCalc_Click() 'validate first textbox With Text1 If Not IsNumeric(Trim(.Text)) Then MsgBox "Invalid entry" .SelStart = 0 .SelLength = Len(.Text) .SetFocus Exit Sub End If End With 'validate second textbox With Text2 If Not IsNumeric(Trim(.Text)) Then MsgBox "Invalid entry" .SelStart = 0 .SelLength = Len(.Text) .SetFocus Exit Sub End If End With 'calculate total amount txtTotal.Text = Format(CCur(Text1.Text) + CCur(Text1.Text), "$0.00") End Sub 'to clear all of your texboxes use this: Private Sub cmdClear_Click() Dim txt As Control For Each txt In Me.Controls If TypeOf txt Is TextBox Then txt.Text = "" End If Next txt End Sub
so this is what i have to type in to the command button?
Help me i am stuck
Edit: Added [vbcode][/vbcode] tags for clarity. - Hack
Looks OK to me.
VB Code:
what am i surpose to do now ?
double-click on your total button. if it's named the same, it should jump to this line:VB Code:
Private Sub cmdCalc_Click()
if you have it named something else, then copy the code below that line in your example into the sub, but make sure that you only have one END SUB at the bottom. Include the second sub, if you need it. It belongs after the first END SUB. Place OPTION EXPLICIT at the top of each form to catch undeclared variable errors, and if you have anything named correctly it will let you know.
After i do post 66 what should i next?
This isn't our application. How are we to know what you are supposed to do next?
After you calculate the total, what do you/the application need to happen next?
what i ment was after calclulating the totals what should i do ?
My point is, I don't know what you should do because I don't know what your program is supposed to do.Quote:
Originally Posted by Franklin67
What is your program supposed to do after the calculations have been done?
Anything?
VB Code:
'to calculate totals use this: Private Sub cmdCalc_Click() 'validate first textbox With Text1 If Not IsNumeric(Trim(.Text)) Then MsgBox "Invalid entry" .SelStart = 0 .SelLength = Len(.Text) .SetFocus Exit Sub End If End With 'validate second textbox With Text2 If Not IsNumeric(Trim(.Text)) Then MsgBox "Invalid entry" .SelStart = 0 .SelLength = Len(.Text) .SetFocus Exit Sub End If End With 'calculate total amount txtTotal.Text = Format(CCur(Text1.Text) + CCur(Text1.Text), "$0.00") End Sub
Must i add this line to my summary and calculate button?
Or only calculate button?
Do you need a summary total?
Yes i need to have a summary total to
1 To display the Total Number of pieces
2.The Total Pay
3.Average Pay per person
and i need a Clear button to clear the name and the number of pieces for the current employee (If You what I mean)
Based on what you just said, then, the answer is yes.Quote:
Originally Posted by Franklin67
what do i do next?
Why do I get the ever present feeling that the people on this forum are writing this program, not you.
What do you think you should/need to do next?
The people on this forum ARE writing his program for him. the next time he gets some homework, he'll be back with no code of his own. :sick:
Mr woody they are explaning on how to put the coding
And i am new to VB 6.0
I can't believe the homework is still in progress. :rolleyes:
Sorry man - just couldn't resist. :p
You see i have a lot of things to do I can't complete it quick thats why i ask you Fellas To help me
And, we don't mind helping out at all. If we did, we wouldn't be here. It is just that rather than helping you through a coding problem, it appears that we are writing the code.
If you have some code that isn't working, then post it and someone will be more than happy to help you to get it working.
see thats what friends are for Right ?
VB Code:
[COLOR=Orange]Private Sub cmdcalculate_Click()[/COLOR] 'determine the price and amount due Dim intpieces As Integer Dim curprice As Currency Dim curamountearned As Currency intpieces = Val(txtpieces.Text) 'Validate for missing data and enable summary button after 'the first order has been entered If txtname.Text = "" Then MsgBox "Please Enter Name", vbOKOnly, "Data Entry Error" txtname.SetFocus ElseIf Not IsNumeric(txtpieces.Text) Then MsgBox "Please Enter a Positive Number for the Piece Count", _ vbOKOnly, "Data Entry Error" With txtpieces .Text = "" .SetFocus End With Else cmdsummary.[COLOR=DarkGreen]enable[/COLOR] = True
Is my CmdSummary Statement correct Or must i change to False Or something Else ? :confused:
And I Got This Error
Compile Error
Method Or Data Not found
On what line does the error occur?Quote:
Originally Posted by Franklin67
VB Code:
cmdsummary.enable = True
Line
You are missing a "d".Quote:
Originally Posted by Franklin67
VB Code:
cmdSummary.Enabled = True
VB Code:
calculate the pay cyramountearned = intpieces * curprice lblamountearned.Caption = FormatCurrency(curamountearned) 'add to totals mintpiecestotal = mintpiecestotal + intpieces mintemployeecount = mintemployeecount + 1 mcurpaytotal = mcurpaytotal + curamountearned End If
cyramountearned = intpieces * curprice
Now This line Has the error
How are each of the three defined?
cyramountearned = intpieces * curprice
SPELLING AGAIN! "u" not "y"
VB Code:
[COLOR=DarkGreen]lblamountearned[/COLOR].Caption = FormatCurrency(curamountearned)
Now This Line
Has the Error
Compile Error
Varible Not Defined
Which variable isn't defined?
lblamountearned or curamountearned?
lblamountearned
Quote:
Originally Posted by Franklin67
Then, that label doesn't exist. Put a lable on your form and call it that and you will be all set.Quote:
Originally Posted by Franklin67
where do i add
lblamountearned
In the new label ?
Put it on your form where it would seem to be the most appropriate.
What is it used for?
lblamountearned.Caption = FormatCurrency(curamountearned)
I mean where do i place this line To mY new label ?
What triggers that calculation?
VB Code:
'calculate the pay Curamountearned = intpieces * Curprice lblamountearned.Caption = FormatCurrency(Curamountearned) 'add to totals mintpiecesTotal = mintpiecesTotal + intpieces mintemployeecount = mintemployeecount + 1 Mcurpaytotal = Mcurpaytotal + Curamountearned End If
Ok. On the surface, this looks fine. What is the issue?
After i Created the new label inserted the coding inside it
mintpiecesTotal = mintpiecesTotal + intpieces
mintemployeecount = mintemployeecount + 1
Mcurpaytotal = Mcurpaytotal + Curamountearned
The one in the dark Green Is error
when i click the calculate button varible not defined
:confused: :wave:
Then, define itQuote:
Originally Posted by Franklin67
VB Code:
Dim mintemployeecount As Integer
Okay That Worked For Employee count
Only The total amout oF Money
Total pieces
Money (Per person)
average
Sumary button Does not work
What is the code and what are the errors?
VB Code:
Private Sub cmdcalculate_Click() 'Determined The Amount Due Dim intpieces As Integer Dim Curprice As Currency Dim Curamountearned As Currency intpieces = Val(txtpieces) 'Validate for missing data and enable summary button after 'the first order has been entered If txtname.Text = "" Then MsgBox "Please Enter Name", vbOKOnly, "Data Entry Error" txtname.SetFocus ElseIf Not IsNumeric(txtpieces.Text) Then MsgBox "Please Enter a Positive Number for the Piece Count", _ vbOKOnly, "Data Entry Error" With txtpieces .Text = " " .SetFocus End With Else cmdsummary.Enabled = True ' Find person with greatest number of pieces If intpieces > MintHighestpieces Then 'compare to current winner MintHighestpieces = intpieces Mstrhighname = txtname.Text End If 'find pay rate If intpieces < 200 Then Curprice = 0.5 ElseIf intpieces < 400 Then Curprice = 0.55 ElseIf intpieces < 600 Then Curprice = 0.6 Else Curprice = 0.65 End If 'calculate the pay Curamountearned = intpieces * Curprice lblamountearned.Caption = FormatCurrency(Curamountearned) 'add to totals mintpiecesTotal = mintpiecesTotal + intpieces Dim mintemployeecount As Integer Mcurpaytotal = Mcurpaytotal + Curamountearned End If End Sub Private Sub cmdexit_Click() End End Sub Private Sub cmdsummary_Click() 'Calculate the average and dispaly the totals Dim curaveragepay As Currency Dim strmessage As String curaveragepay = Mcurpaytotal / mintemployeecount strmessage = "Total number of pieces " & mintpiecesTotal & vbCrLf & _ "Average Pay: " & FormatCurrency(curaveragepay) & cbCrLf & _ "Person producing most: " & Mstrhighname & vbCrLf & _ " (produced " & MintHighestpieces & " pieces)" MsgBox strmessage, vbOKOnly, "Piecework Summary" End Sub Private Sub Form_Load() 'Initialise the variables MintHighestpieces = -1 End Sub Private Sub Label1_Click() 'calculate the pay Curamountearned = intpieces * Curprice lblamountearned.Caption = FormatCurrency(Curamountearned) End Sub
Half Of Them Are corrrect But I* don't know which one ? :confused:
When your program encounters an error, a message box will pop with the error message. I need to know what that is.
When you click on the debug button on the messagebox it will take you to the place where the error occured. I need to know what/where that is.
Private Sub Form_Load()
'Initialise the variables
MintHighestpieces = -1
End Sub
Error
Or Calculations
Franklin, saying Error does me no good.
What is the error?
There Is no error All is okay but i got the Dim mintemployeecount As Integer right When i click The Calculate Button Only The Name of the person & The number of pieces
It Gives the correct answer But Can't clear Off The number
and i need help with the rest
What is the rest that you need help with?
Only The total amout oF Money
Total pieces
Money (Per person)
average
Sumary button Does not work
What is the code in the summary button that does not work?
What should it be adding together to get a summary? (I need the variables you have created for this)
Here my Label Text boxes Names
lblaverage
lblmoney
lblpieces
Lbltotal money
Last One That Work Perfectly Okay : Lblblamountearned
Enter Name
Enter Number of pieces
Pieces Completed
1-199
200-399
400-599
600 Or more
Price Paid per Piece
$0.50
$0.55
$0.60
$0.65
summmary button
curaveragepay = Mcurpaytotal / mintemployeecount
strmessage = "Total number of pieces " & mintpiecesTotal & vbCrLf & _
"Average Pay: " & FormatCurrency(curaveragepay) & cbCrLf & _
"Person producing most: " & Mstrhighname & vbCrLf & _
" (produced " & MintHighestpieces & " pieces)"
MsgBox strmessage, vbOKOnly, "Piecework Summary"
Does not work
Ok. I have just read this thread and got completely confused.
Franklin67, you really, really must state exactly what code, errors or problems you are dealing with.
Just saying "it doesn't work", or posting a post like your very 1st one in this thread, is no good to anyone :(
I am still a little confused as to what your problem is.
A little tip for you. Add:
to the top of every module, class or form.VB Code:
Option Explicit
This will automatically let you know if you have no declared any varible.
VB can do this automatically when you create a new class or form. You can do this by going to Tools...Options...then tick "Require Varible Declaration"
Woof
What should it be adding together to get a summary? (I need the variables you have created for this)
Private Sub cmdsummary_Click()
'Calculate the average and dispaly the totals
Dim curaveragepay As Currency
Dim strmessage As String
curaveragepay = Mcurpaytotal / mintemployeecount
strmessage = "Total number of pieces " & mintpiecesTotal & vbCrLf & _
"Average Pay: " & FormatCurrency(curaveragepay) & cbCrLf & _
"Person producing most: " & Mstrhighname & vbCrLf & _
" (produced " & MintHighestpieces & " pieces)"
MsgBox strmessage, vbOKOnly, "Piecework Summary"
I don't where to put them ?
Can some check For me this and Then you will know what i mean
I am also Confused :confused: