Results 1 to 8 of 8

Thread: need help with a program

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2007
    Posts
    9

    need help with a program

    This program gives you the option of picking 3 different rental cars. Jeep Wrangler which cost $55 per day, Grand Cherokee which cost $85 per day, and a Land Rover which cost $125 dollars per day. You also have an option to refill the gas for $52. The program needs to calculate the total cost.

    here my code, but its didnt work:
    vb Code:
    1. Private Sub Command1_Click()
    2. Dim sngWrangler As Single, sngGrand As Single
    3. Dim sngTotal As Single, sngRover, sngDays As Single
    4.  
    5. 'assighn the variables
    6. sngDays = cboDays.Text
    7. 'make calculations
    8. sngTotal = (sngWrangler * sngDays) + (sngGrand * sngDays) + (sngRover * sngDays)
    9. 'display the results on the screen
    10. lblTotal.Caption = sngTotal
    11.  
    12. End Sub
    13.  
    14. Private Sub Form_Load()
    15. cboDays.AddItem 1
    16. cboDays.AddItem 2
    17. cboDays.AddItem 3
    18. cboDays.AddItem 4
    19. cboDays.AddItem 5
    20. cboDays.AddItem 6
    21. cboDays.AddItem 7
    22.  
    23. End Sub
    24.  
    25. Private Sub optRover_Click()
    26. If optRover.Value = True Then
    27.     sngRover = 125
    28. Else
    29.     sngRover = 0
    30. End If
    31. End Sub
    32.  
    33. Private Sub optWrangler_Click()
    34. If optWrangler.Value = True Then
    35.     sngWrangler = 55
    36. Else
    37.     sngWrangler = 0
    38. End If
    39. End Sub
    40.  
    41. Private Sub optGrand_Click()
    42. If optGrand.Value = True Then
    43.     sngGrand = 85
    44. Else
    45.     sngGrand = 0
    46. End If
    47. End Sub
    48.  
    49. Private Sub chkGas_Click()
    50.  
    51. If chkGas.Value = 1 Then
    52.     sngGas = 52
    53. Else
    54.     sngGas = 0
    55. End If
    56.  
    57. lblTotal.Caption = ""
    58. End Sub
    Last edited by Hack; Mar 19th, 2007 at 08:30 AM. Reason: Added VB Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width