-
errr..Stuck?need help as soon as possible
hi i am currently super stuck in one of my project as i am still not very used to PROGRAMMING...do not know how to fix the error....relli totally stuck...tried everything....so could some1 help me?
The project is about a uni cake shop sells a selection of cakes to be bought for eating in and take away. Required to develop a solution that can be use as a point of sales register to record and calculate the amount ddue for individual orders and maintain accumulated totals of each type of cake sold, total number of orders, total revenu and total GST collected to create a summary of the day's sales. Payment is cash. GST charges is 8%, eat in service charge is 10% but not on take away. Extra cream; choc cream, strawberry and blueberry is 0.5 perpacket each.
Requirements:
login = 3 times only
must show boolean flag variable
multiform for login and order
Before quiting display summary sales.
And show number of order.
require to use sub/fuction
do not require database
This is what i have done so far...which is like totally wrong i think..So pls...help me!!i relli reli tried my best...
The error would most likely be the function on the form2's code
VB Code:
Function Login(ByVal Username As String, ByVal Password As String) As Boolean
If Username = "pieuser1" And Password = "piepass1" Then
Login = True
End If
End Function
'Form1's code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim secondForm As New Form2 'Instantiate the second form
Dim username As Boolean
username = Login(Me.txtuser.Text, Me.txtpassword.Text)
If username = True Then
MessageBox.Show("You've successfully logged In!", _
"Verified User", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
secondForm.ShowDialog() 'Show the second form
Else
MessageBox.Show("Try again - login information is incorrect!", _
"Access Denied", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
End If
End Sub
'Form2's code
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim total As Double
Dim sauce, serve, subtotal As Double
sauce = CDbl(txttomato.Text) * 0.5 + CDbl(txtbbq.Text) * 0.5 + CDbl(txtchilli.Text) * 0.5
subtotal = ((CDbl(txtmeat.Text) * CDbl(txtp1.Text) + CDbl(txtveggie.Text) * CDbl(txtp2.Text) + CDbl(txtchicken.Text) * CDbl(txtp3.Text) + CDbl(txtcurry.Text) * CDbl(txtp4.Text) + CDbl(txtbeef.Text) * CDbl(txtp5.Text) + CDbl(txtham.Text) * CDbl(txtp6.Text)))
total = subtotal + sauce
txttotal.Text = "RM" & Str(total)
End Sub
Sub serve(ByRef total As Double, ByRef serve As Double)
If raddine.Checked Then
serve = 0.1 * total
End If
If radtake.Checked Then
serve = 0.08 * total
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim change As Double
change = CDbl(txtpayment.Text) - CDbl(txttotal.Text)
txtchange.Text = "RM" & Str(change)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'To clear all the contents in text boxes
txtmeat.Clear()
txtveggie.Clear()
txtchicken.Clear()
txtcurry.Clear()
txtbeef.Clear()
txtcurry.Clear()
txtham.Clear()
txtpayment.Clear()
txtchange.Clear()
txttomato.Clear()
txtbbq.Clear()
txtchilli.Clear()
txttotal.Clear()
raddine.Checked = False
radtake.Checked = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
-
Re: errr..Stuck?need help as soon as possible
first thing first..format your code so that it can easily read. use vbcode tags to format your code. [vbcode]'your code here[/vbcode]
second what is the error?
-
Re: errr..Stuck?need help as soon as possible
i think the error is the function prt
-
Re: errr..Stuck?need help as soon as possible
But you still havent said what the error is?
-
Re: errr..Stuck?need help as soon as possible
Sub serve(ByRef total As Double, ByRef serve As Double)
If raddine.Checked Then
serve = 0.1 * total
End If
If radtake.Checked Then
serve = 0.08 * total
End If
i think this prt is the one with error...cos everytime i debug the it....it gives me the total of cakes....and it doesnt include the taxes
-
Re: errr..Stuck?need help as soon as possible
and also i relli relli duno how to display the summary at the end, which shows the number of order taken, the total revenue etc...and i dunno how to do the prt that it allows the user to try 3 times login
-
Re: errr..Stuck?need help as soon as possible
Oh so its not an actual error but a miscalculation issue. Your declaring a variable serve but its the same name as your sub serve.
Plus your not calling serve anywhere at all so it doesnt get added in.
-
Re: errr..Stuck?need help as soon as possible
hmmm...so how i am suppose to fix?cos i relli dunno............do u mind if u could tech me?cos i relli dunno..
i am pretty dumb at vb.net......
-
Re: errr..Stuck?need help as soon as possible
Remove the serve variable in Button4_click event. Then add something like...
total = subtotal + sauce + serve(total)
Also, change the signature of server so you only pass the total byval and return serve.
VB Code:
Private Sub serve(ByVal total As Double) As Double
-
Re: errr..Stuck?need help as soon as possible
ok,...so do i like remove (the one tat i underlined)
VB Code:
Dim total As Double
Dim sauce, [U]serve,[/U] subtotal As Double
sauce = CDbl(txttomato.Text) * 0.5 + CDbl(txtbbq.Text) * 0.5 + CDbl(txtchilli.Text) * 0.5
subtotal = ((CDbl(txtmeat.Text) * CDbl(txtp1.Text) + CDbl(txtveggie.Text) * CDbl(txtp2.Text) + CDbl(txtchicken.Text) * CDbl(txtp3.Text) + CDbl(txtcurry.Text) * CDbl(txtp4.Text) + CDbl(txtbeef.Text) * CDbl(txtp5.Text) + CDbl(txtham.Text) * CDbl(txtp6.Text)))
[U] total = subtotal + sauce[/U] change this to total = subtotal + sauce + serve(total)
txttotal.Text = "RM" & Str(total)
-
Re: errr..Stuck?need help as soon as possible
err neway i have tried the way u ask me to change but it dosnt seem to work..it stills doesnt count the taxes in.....srry if i am relli bothering u..
-
Re: errr..Stuck?need help as soon as possible
and dont forget to change this one:
VB Code:
Sub serve(ByRef total As Double, ByRef serve As Double)
If raddine.Checked Then
serve = 0.1 * total
End If
If radtake.Checked Then
serve = 0.08 * total
End If
End Sub
'to this one.
Function serve(ByRef total As Double) as double
If raddine.Checked Then
serve = 0.1 * total
End If
If radtake.Checked Then
serve = 0.08 * total
End If
Return serve
End Sub
'and in your button click
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim total As Double
Dim sauce, serve, subtotal As Double
sauce = CDbl(txttomato.Text) * 0.5 + CDbl(txtbbq.Text) * 0.5 + CDbl(txtchilli.Text) * 0.5
subtotal = ((CDbl(txtmeat.Text) * CDbl(txtp1.Text) + CDbl(txtveggie.Text) * CDbl(txtp2.Text) + CDbl(txtchicken.Text) * CDbl(txtp3.Text) + CDbl(txtcurry.Text) * CDbl(txtp4.Text) + CDbl(txtbeef.Text) * CDbl(txtp5.Text) + CDbl(txtham.Text) * CDbl(txtp6.Text)))
total = subtotal + sauce
txttotal.Text = "RM" & Str(total) + serve(total)
End Sub
-
Re: errr..Stuck?need help as soon as possible
omg thank u sooo much relli apperiate ur help....err one more thing i dunno how to make the login part where user is allow to login 3 times...this is wat i have done...i know we r supposed to use counter but i just dunno where to insert it in my codings..lol....relli relli tahnk uagain
Function Login(ByVal Username As String, ByVal Password As String) As Boolean
If Username = "pieuser1" And Password = "piepass1" Then
Login = True
End If
End Function
'Form1's code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim secondForm As New Form2 'Instantiate the second form
Dim username As Boolean
username = Login(Me.txtuser.Text, Me.txtpassword.Text)
If username = True Then
MessageBox.Show("You've successfully logged In!", _
"Verified User", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
secondForm.ShowDialog() 'Show the second form
Else
MessageBox.Show("Try again - login information is incorrect!", _
"Access Denied", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
End If
End Sub
-
Re: errr..Stuck?need help as soon as possible
ok here's your code.
try that one if that fits your needs.
VB Code:
Function Login(ByVal Username As String, ByVal Password As String) As Boolean
If Username = "pieuser1" And Password = "piepass1" Then
Login = True
End If
End Function
'Form1's code
Dim checklogin As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.checklogin = 3 Then
MessageBox.Show("You exceeded the limit to login. Prepare to die!!!.muwahahahah", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Exit Sub
End If
Dim secondForm As New Form2() 'Instantiate the second form
Dim username As Boolean
username = Login(Me.txtuser.Text, Me.txtpassword.Text)
If username = True Then
MessageBox.Show("You've successfully logged In!", _
"Verified User", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
secondForm.ShowDialog() 'Show the second form
Else
Me.checklogin += 1
MessageBox.Show("Try again - login information is incorrect!", _
"Access Denied", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
End If
End Sub
-
Re: errr..Stuck?need help as soon as possible
thank u thank u...it fits exactly my needs!!thank u thank u ....if u didnt help me i think i would have stayed blank forever...
anyway i am still pretty stuck at this prt...at this prt wen i click on new order button, it will clear the all the textboxes....and at the quit button prt..i am supposed to ask whether th user wan to quit..if no it will go bck to the order form..if yes it will display the summary of the sales such as the demand of the various goods, accumulated totals, accumulated for GST and service charges and also the number of orders for that day in a list box...tis is the prt i am relli stuck as i don't know how to do..so pls help me for the last time in this..thank u
VB Code:
Private Sub Neworder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'To clear all the contents in text boxes
txtmeat.Clear()
txtveggie.Clear()
txtchicken.Clear()
txtcurry.Clear()
txtbeef.Clear()
txtcurry.Clear()
txtham.Clear()
txtpayment.Clear()
txtchange.Clear()
txttomato.Clear()
txtbbq.Clear()
txtchilli.Clear()
txttotal.Clear()
raddine.Checked = False
radtake.Checked = False
End Sub
Private Sub quit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
End Class
-
Re: errr..Stuck?need help as soon as possible
in your quit button click event put this one.
VB Code:
If MessageBox.Show("Are you sure you want to quit using illegal drugs?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.No Then
'do your thing here
'put your code here in displaying the summary of your sales
End If
'sorry i can't do all things for you..i have work to do here..
'maybe next time
-
Re: errr..Stuck?need help as soon as possible
ohok understand..u have alredi helped me enugh..thank u so much again...relli srry to bother ya
-
Re: errr..Stuck?need help as soon as possible
-
Re: errr..Stuck?need help as soon as possible
anyway i am still pretty stuck at this prt...at this prt wen i click on new order button, it will clear the all the textboxes and as it clear the order it records it in the summary of the sales such as the demand of the various goods, accumulated totals, accumulated for GST and service charges and also the number of orders for that day in a list box...and each time wen i press new order it will total up as well in the sumaary box(listbox)tis is the prt i am relli stuck as i don't know how to do..so pls help me anyone..thank u
visual basic code:--------------------------------------------------------------------------------Private Sub Neworder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'To clear all the contents in text boxes
txtmeat.Clear()
txtveggie.Clear()
txtchicken.Clear()
txtcurry.Clear()
txtbeef.Clear()
txtcurry.Clear()
txtham.Clear()
txtpayment.Clear()
txtchange.Clear()
txttomato.Clear()
txtbbq.Clear()
txtchilli.Clear()
txttotal.Clear()
raddine.Checked = False
radtake.Checked = False
End Sub
End Class
-
Re: errr..Stuck?need help as soon as possible
i am seriously stuck...i relli dunno how to do tat part...wish some1 would help me again..
-
Re: errr..Stuck?need help as soon as possible
Your code clears the controls, but what is left thats the issue?
-
Re: errr..Stuck?need help as soon as possible
but i am supposed to show the whole business summary...wat i am trying to do is tat wen the user press on the new order, it clears of the recent orders, and then it will record it in to the listbox, which is the whole summary business transaction...so at the end this listbox will show all the no. of orders it has, the total GST and service taxes accumulated, the total cost, and the number of meat, veggie etc tat has been sold......i have already tried and yet failed...ask my friend and everybody i know..and it turns out they don't know.........so my last option is to ask from u guys..................so please help me......
-
Re: errr..Stuck?need help as soon as possible
Well it a bit hard to understand what you program needs when I cant see it, but is that all the code?
Its easier to break it down into smaller manageable tasks. So what would be the first step? Clearing the listbox after the textboxes are cleared?
-
Re: errr..Stuck?need help as soon as possible
ok ere issit..i attach it...hope u can help me
-
Re: errr..Stuck?need help as soon as possible
I dont have winrar so I cant view all the code. What is the first action needing after the clearing of the textboxes?
-
Re: errr..Stuck?need help as soon as possible
i have changed zip file for ya..its like wen the user click on the new order..it will clear the orders then the data will be display in the listbox(which is the business summary)
-
Re: errr..Stuck?need help as soon as possible
so pls helpppp anyone..... :'(
-
Re: errr..Stuck?need help as soon as possible
I'm back, loooking at the zip now. ;)
-
Re: errr..Stuck?need help as soon as possible
Ok, first errors I got are if you dont have a number in all textboxes, when it tries to calculate the total it crashes. So we need to
only add the boxes that are filled in or have them always have a zero value as a default.
What would be a sample text entry in the listbox?
-
Re: errr..Stuck?need help as soon as possible
yeah i realised tat to...
well the sample text entry in the textbox would be the business sumarrr for the day
it would look something like tis:
business summary of the day:
number of order for the day=
demand for each pie:
meat =
veggie =
etc
total pies demanded =
taxes:
GST=
Service Tax:
total taxes:
total accumulated:
total sale of the day =
-
Re: errr..Stuck?need help as soon as possible(Done)
ok phew..manage to fix the errors nad mistakes..thanks for all ur help!