1 person costs $695.00
2-4 people costs $545
5-8 people costs $480
8 or more costs $395
If the company has been before they get a 15% discount and no company can have more than 16 people. The program asks that the user enters valid data.?? (error msg boxes)
A way for you to start this (assignment?) would be to create an integer variable for number of people, decimal for cost, and a boolean variable for if a company has attended before.
You may want to receive input from the user with a textbox, a checkbox, and a button, and display the results in a label.
From the textbox would be the count of users, the checkbox if they've attended before. Within the button, you would want either Select Case or if you haven't learned this for your class (i'm assuming), use nested IF statements to assign a value to your cost variable. And also, check for the selection of the checkbox. If it is, assign cost as 85% of itself and display results. If not, do not apply the discount.
I think you are going to have to provide just a bit more information then, I want to make a program do this...... How do I do it?
With that said I feel your pain as starting out and not knowing were to begin. Sounds like you have an idea and not sure where to go next?
Check out www.homeandlearn.co.uk vb.net for beginners, it will introduce you to basic concepts of inputting data, validating and calculating as well as "IF" statements, checkboxes and more...
If > this many people then> this price etc....
Then write out hte steps on paper and tackle each one at a time, example
1. Place to enter data
2. Validate Data
3. Calculate
etc...
If I am wrong and you have some code going already and just stuck in a particular area go ahead and post the code as to what you have so far, its also a good idea to let people knopw what version of VB you are working with.
Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
Private Sub DataGridView1_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
' Attempt to cast the EditingControl to a ComboBox.
That was a little in depth for the class Im in. I am in my 1st class of Visual Basic 2010 Express.
We are just doing strings, decimals, If, ElseIF and now radio buttons. I just seem to get confused when it comes to actually writing the code.
I have my # of employees set up in a text box
I have the prices in labels
and I have a radio button set up to push if your a returning company
The total cost is set up as a label
I have a calculate button
I have a label to enter the amount of employees attending
A text box where the company enters their name.
That was a little in depth for the class Im in. I am in my 1st class of Visual Basic 2010 Express.
We are just doing strings, decimals, If, ElseIF and now radio buttons. I just seem to get confused when it comes to actually writing the code.
I have my # of employees set up in a text box
I have the prices in labels
and I have a radio button set up to push if your a returning company
The total cost is set up as a label
I have a calculate button
I have a label to enter the amount of employees attending
A text box where the company enters their name.
Please Help
Post what you have so far:
Here is a very basic general idea for radiobuttons again the website I posted will help you alot
If RadioButton1.Checked= True Then
If RadioButton1.Checked=True AND TextBox1.Text=#ofEmployees Then
As you should be learning the code and not regurgitating it, I will give you a portion of what you would likely use for this assignment. Some of it is blank intentionally so you can learn this on your own.
Code:
Dim persons As Integer = NumericUpDown1.Value 'this could be a textbox if you chose, however you can have input validation problems without additional code.
Dim cost As Decimal
If persons = 1 Then
cost = persons * 695
ElseIf persons > 1 And persons <= 4 Then
cost = persons * 545
' fill in the blank here
End If
If CheckBox1.Checked Then 'easily replaced with a radiobutton if that is your choice
' this is if the company has attended before, if so, change the value of cost here.
End If
Label1.Text = String.Format("{0:c}", cost) 'this displays the total cost to appear in normal currency format.
Thanks again guys for chiming in on my request for help.
I would just assume copy the code I do not want to be a programmer. This is just what I have to do to complete my school.
I have no desire to program. I just want to get finished.
Do I need to do the string and intergers and then do the code? I just don't know or desire to know all this mess. I transferred into this school and it is part of their program.
I know that sounds nuts but, really I don't want to be a programmer. So If you could help me out that would be great.
Here is what you would be likely to use for a basic class and would cover the most likely used commands. The exception is that you may not have used String.Format yet, and if so, set the label text to something like: "$" & cost
Code:
Dim persons As Integer = NumericUpDown1.Value
Dim cost As Decimal
If persons = 1 Then
cost = persons * 695
ElseIf persons > 1 And persons <= 4 Then
cost = persons * 545
ElseIf persons > 4 And persons <= 8 Then
cost = persons * 480
ElseIf persons > 8 Then
cost = persons * 395
End If
If CheckBox1.Checked Then
cost *= 0.85
End If
Label1.Text = String.Format("{0:c}", cost)
I am getting a msg telling me that a non-shared member requires an object reference. It is telling me that where I have it Bold and Underlined. Can you help again?????
Victoria
Private Sub grpADSEConference_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpADSEConference.Enter
Dim persons As Integer =NumericUpDown.Value
Dim cost As Decimal
If persons = 1 Then
cost = persons * 695
ElseIf persons > 1 And persons <= 4 Then
cost = persons * 545
ElseIf persons > 4 And persons <= 8 Then
cost = persons * 480
ElseIf persons > 8 Then
cost = persons * 395
End If
If raddiscount.Checked Then
cost *= 0.85
End If
lblcostforcompany.Text = String.Format("{0:c}", cost)
End Sub
End Class
I put in a NumericUpDown control on my test project. It appears to me that you do not have one. Change that line to read TextBox1.Text instead and delete that private function you had created.
Now it says conversion from type string to interger is not valid. When casting from a number it must be less than enfinity???? OMG....I could never do what you guys do.....
Private Sub grpADSEConference_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpADSEConference.Enter Dim persons As Integer = txtnumberofemployees.Text
OK so now the stupid thing (Im the stupid one) won't calculate when I push calculate. I have the calculate button and a label box where the cost of employees is suppose to show up.
If you're using the .TryParse code, it will assign 0 to persons if you have something that can't be converted to a number. Is the label completely blank or showing $0?
Ok Skor 13 I am sending you the whole thing so you can see it.....
Public Class frmActiveDevelopersSkillEnhancement
Private Sub grpADSEConference_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpADSEConference.Enter
Dim persons As Integer
Integer.TryParse(txtnumberofemployees.Text, persons)
Dim cost As Decimal
If persons = 1 Then
cost = persons * 695
ElseIf persons > 1 And persons <= 4 Then
cost = persons * 545
ElseIf persons > 4 And persons <= 8 Then
cost = persons * 480
ElseIf persons > 8 Then
cost = persons * 395
End If
If raddiscount.Checked Then
cost *= 0.85
End If
lblcostforcompany.Text = String.Format("{0:c}", cost)
End Sub
Private Sub frmActiveDevelopersSkillEnhancement_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
I tested the code just now and it works just fine. The only thing I can't check is the grpADSEConference.Enter event. What is grpADSEConference anyway? You just need to be sure that the code is being triggered after they input the data.
button 1...just make a button??? On my other projects this is how the calculate button is set up....
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
' The calculate event handler calculates the gross pay, taxs due, and the net pay based on the
' hours worked, hourly pay, and checking one of the tax rate radio buttons.
Dim strtxtHours As String
Dim inttxtHours As Decimal
Dim strtxtPayPerHour As String
Dim inttxtPayPerHour As Decimal
Dim declblTotalGrossPay As Decimal
Dim declblTotalTaxDues As Decimal
Dim declblNetPay As Decimal
Dim decTaxRate As Decimal
I don't know what you mean. Gosh I'm sorry...I just don't get this programming stuff.
I have a calculate button on my project and a label box for where the amount is suppose to show up.
For many calculations, you use a button. The latest example you posted appears to be a button sub. Just do what .paul.'s last post says, select and cut all that code and paste it into the button sub.
I just don't know.... Here is what I have so far....Please tell me what to do...
I don't know how or where to do or make it calculate...It is showing $0.00
Private Sub grpADSEConference_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles grpADSEConference.Enter
Dim persons As Integer
Integer.TryParse(txtnumberofemployees.Text, persons)
Dim cost As Decimal
If persons = 1 Then
cost = persons * 695
ElseIf persons > 1 And persons <= 4 Then
cost = persons * 545
ElseIf persons > 4 And persons <= 8 Then
cost = persons * 480
ElseIf persons > 8 Then
cost = persons * 395
End If
If raddiscount.Checked Then
cost *= 0.15
End If
lblcostforcompany.Text = String.Format("{0:c}", cost)
End Sub
Private Sub frmActiveDevelopersSkillEnhancement_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
grpADSEConference.Focus()
End Sub
I did read #27...I just don't get it. Please see what I sent you last and tell me where to put what. I can double click on the calculate button and go into design mode..what do I put in the code for the calculate button??
The design view is what your program looks like. The window, buttons, textboxes etc... When you double click on one of those objects, most cases will automatically open up the code window and either add or bring you to the click event for that object. From there, you need to paste all of that code that is within the Sub you posted into this new button click event.
i think you should make an effort + really try with your programming class instead of looking at it as something you're completely not interested in that you're only doing grudgingly as a means to an end.
you might find you enjoy it if you weren't fighting it every step of the way + you would definitely learn more in all aspects + not just vb.net if your attitude was better