 |
|
 |
dollyp Level: Trainee
 Registered: 07-06-2010 Posts: 1
|
Help with codes
I need help with the codes for the following....
Minimum Requirements
•Create a form with the following objects labeled appropriately:
◦Start Date (date/time picker)
◦End Date (date/time picker)
◦Campsite Type (radio buttons for Basic, Intermediate, Best)
◦Electric Required? (check box)
◦Daily Rate (read-only text box, formatted as currency)
◦Number of Days (read-only text box)
◦Subtotal (read-only text box, formatted as currency)
◦Electricity surcharge (read-only text box, formatted as currency)
◦Total (read-only text box, formatted as currency)
◦Calculate button (initiates calculations)
◦Reset button (sets all fields back to original values)
◦Exit button with confirmation from the user
•Site charges
◦Basic = $25/day
◦Intermediate = $35/day
◦Best = $50/day
•Daily rate will display the previously mentioned values depending on which site type is selected.
•Number of Days will display difference (in days) between the Start and End Dates (hint, use DateDiff function for this calculation).
•Subtotal is the site charge multiplied by the daily rate.
•Electricity charge is $10 additional per day if selected.
•Total is subtotal + electricity charge.
•Read-only fields should only be updated when either the calculation or reset button is pressed. Do not use content update event handlers for these updates.
•Do not allow the user to resize the form.
•Remove minimize, maximize, and close buttons from the title bar.
Additional Notes
|
|
07-06-2010 at 06:44 PM |
|
|
haxialelite Level: Trainee
 Registered: 09-06-2010 Posts: 3
|
Re: Help with codes
quote: dollyp wrote:
I need help with the codes for the following....
Minimum Requirements
•Create a form with the following objects labeled appropriately:
◦Start Date (date/time picker)
◦End Date (date/time picker)
◦Campsite Type (radio buttons for Basic, Intermediate, Best)
◦Electric Required? (check box)
◦Daily Rate (read-only text box, formatted as currency)
◦Number of Days (read-only text box)
◦Subtotal (read-only text box, formatted as currency)
◦Electricity surcharge (read-only text box, formatted as currency)
◦Total (read-only text box, formatted as currency)
◦Calculate button (initiates calculations)
◦Reset button (sets all fields back to original values)
◦Exit button with confirmation from the user
•Site charges
◦Basic = $25/day
◦Intermediate = $35/day
◦Best = $50/day
•Daily rate will display the previously mentioned values depending on which site type is selected.
•Number of Days will display difference (in days) between the Start and End Dates (hint, use DateDiff function for this calculation).
•Subtotal is the site charge multiplied by the daily rate.
•Electricity charge is $10 additional per day if selected.
•Total is subtotal + electricity charge.
•Read-only fields should only be updated when either the calculation or reset button is pressed. Do not use content update event handlers for these updates.
•Do not allow the user to resize the form.
•Remove minimize, maximize, and close buttons from the title bar.
Additional Notes
You can set your textbox properties to ReadOnly from the "Properties Toolbar (on the right of your designer)" or via code by:
TextBox1.ReadOnly=True
'if you want certain textboxes to always be ReadOnly, then I would reccommend setting it up in the designer to do so; or if you prefer it in code; then set it up on the Form LoadEvent by double-clicking the form and adding the code there:
TextBox1.ReadOnly=True
TextBox2.ReadOnly=True
...and so on
'To remove the minimize, maximize, and close buttons from the form you can either set the FormBordedrProperty to NONE in the designer; or through code:
Me.BorderStyle=BorderStyle.None 'On the FormLoad event
NOTE: Doing it the above way will prevent users from moving your form also
'or, you can do it by selecting the ControlBox property in the designer, and setting it to False.
'set the Form to not allow resize by selecting (in the designer) the AllowResize property and set it to False, or in code:
(at the FormLoad event)
me.AllowResize=False
And you are the winner of the extra bonus:
If you want to make your form TopMost (above everything); set its TopMost property (in the designer) to True, or in code:
(yep, FormLoad event also)
me.TopMost=True
Your RESET button could do the following: (I assume you mean "Back to their original values", meaning blank)
TextBox1.Clear 'rename these to your textbox names
TextBox2.Clear
....and so on.
Or by:
TextBox1.Text=""
TextBox2.Text=""
...and so on.
EXIT button:
If msgbox("Are you sure to exit?","Confirmation",Windows.Forms.DialogButtons.YesNo) = windows.forms.DialogResult.Yes THEN
END 'closes the app
ELSE
RETURN 'returns to the main form without closing
End If
for your Campsite type/charges (using radiobuttons):
you could declare some variables to hold the charges:
Dim intBasic as Integer=25
Dim intInterm as Integer =35
Dim intBest as Integer=50
'You could use SELECT CASE statements, but I am partial to IF statements myself, so..
'double-click the radio button BASIC and add this to its CheckedChanged event
If rbBasic.checked=true then
rbBasic.enabled=false 'we disable the control to force them to pick an option
rbInter.enabled=true
rbInter.checked=false 'make sure multiple options are not allowed
rbBest.enabled=true
rbBest.checked=false
txtDailyRate.text=intBasic.ToString
Else
'do nothing
End If
'On the radio button Intermediate CheckedChanged event
If rbInter.checked=True then
rbInter.enabled=false
rbBasic.checked=False
rbBasic.enabled=True
rbBest.enabled=true
rbBest.checked=false
txtDailyRate.text=intInterm.ToString
Else
'do nothing
End If
'and on the Best button CheckedChanged event
If rbBest.checked=true
rbBest.enabled=false
rbBasic.checked=False
rbBasic.enabled=True
rbInter.checked=False
rbInter.enabled=True
txtDailyRate.text=intBest.ToString
Else
'do nothing
End If
'this prevents more than one radio button being selected at any one time
'on the Calculate button click event (double click it to edit)
Dim strDays as string = DateTimePicker2.text - DateTimePicker1.text
'DateTimePicker1 is Start Date, DateTimePicker2 is End Date
txtNumberOfDays.text=strDays
txtSubTotal.text= txtNumberOfDays.text * txtDailyRate.text
If chkElectric.checked=true then
txtElecSurcharge.text= txtNumberOfDays.text * "10"
Else
txtElecSurcharge.text="" 'equals nothing if not selected
End If
txtTotal.text= txtSubtotal.text + txtElecSurcharge.text
''Hope this helps in your endeavors; I think I answered it all; It should all work out, off the top of my head ~Happy Coding!
-haxialelite
____________________________
"The tree of knowledge must be refreshed from time to time with perseverance"
|
|
10-06-2010 at 01:05 AM |
|
|
|
|
 |
 |