Attention: PROnetworks has upgraded our forum from phpbb2 to phpbb3!!

Please head over to our new converted forum at: http://www.pronetworks.org/forums/

This old forum will remain 'read-only' until approximately February 2009. We look forward to seeing you at the new forum!
Author Message
thankins
PostPosted: Thu Sep 18, 2003 12:06 pm Reply with quote

PRO Level 2
 
 


Joined: 05 Mar 2003
Posts: 40
Location: USA
Hi guys, hopefully you can help me. I have to do this program for class and can't seem to figure out what to do. and the d*mn tutorials are helping.

Here is my problem: Create a program where user should select the package for the customer from a set of radio button and enter the number of hours used. A check box captioned "Non-Profit Organization" should also appear on the form. The application should calculate and display the total due. If the user selects "Non Profit Org" check box a 20% discount should be deducted.
Package A: 10 hours for 9.95 Addition Hours 2.00 per hour
Package B: 20 hours for 14.95 Addition Hours 1.00 per hour
Package C: Unlimted hours for 19.95


I have the layout done and all that but I dont know how to calculate the addition hours in with price. If you want I could email you the vb file and you could look at it. What should it look like

Please HELP

Travis
 
Back to top
thankins
PostPosted: Thu Sep 18, 2003 12:11 pm Reply with quote

PRO Level 2
 
 


Joined: 05 Mar 2003
Posts: 40
Location: USA
Here is what I have so far for the calulate button:
I also have a const global variable called nonProfit for the 20% discount
I know what to do till I get to the question marks and then I dont know what to type, I typed what is next to ? marks from what I got from an example

Private Sub btbCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbCalc.Click
'Claculates and displays the price for internet usage

'Declare local variables
Dim packageA As Double 'Price for Package A
Dim packageB As Double 'Price for Package B
Dim packageC As Double 'Price for Package C
Dim discount As Double 'Discount
Dim totalFee As Double 'Total Fee


'Validate the number of Hours
If Val(txtHours.Text) < 1 Or Val(txtHours.Text) > 744 Then
MessageBox.Show("Enter a vlaue in the range of 1-744 for " & _
"hours of usage.", "Input Error")
Else
'Calulates the package rate
If radPacA.Checked = True Then
packageA = 9.95
ElseIf radPacB.Checked = True Then
packageB = 14.95
ElseIf radPacC.Checked = True Then
packageC = 19.95

End If

??? 'Calculates the discount for Non Profit Org
??? If chkNonProfit.Checked = True Then
??? packageA = packageA * nonProfit
??? packageB = packageB * nonProfit
?????? packageC = packageC * nonProfit
End If


'Determines the extra charge if any
?????? Select Case Val(txtHours.Text)
Case Is > 10


End Select
End Sub
 
Back to top
thankins
PostPosted: Thu Sep 18, 2003 3:53 pm Reply with quote

PRO Level 2
 
 


Joined: 05 Mar 2003
Posts: 40
Location: USA
anyone? Some please help I am desperate saywhat
 
Back to top
augie
Algis Koscus
PostPosted: Thu Sep 18, 2003 4:07 pm Reply with quote

Community Director
 
 


Joined: 25 Aug 2002
Posts: 17725
Location: Laurentians, Quebec
Just be patient, a couple of knowledgeable people will be on soon. Gotta make money.
 
Back to top
thankins
PostPosted: Thu Sep 18, 2003 4:11 pm Reply with quote

PRO Level 2
 
 


Joined: 05 Mar 2003
Posts: 40
Location: USA
Thanks Auggie, I am just freaking out. Being the bad student I am, I have waited the last minute to do it, and now stressing out! But I will what and see if some of those "money makers" can help! LOL
 
Back to top
Weaver
PostPosted: Thu Sep 18, 2003 4:24 pm Reply with quote

PROfessional Member
 
 


Joined: 18 Jun 2002
Posts: 2587
Location: /home/weaver/
Glad to see you have made it this far. I have never touched Visual Basic, so you will have to bear with me.

From what I can tell you are having problems just figuring out the final total for a given number of hours based on the specified package type. I'll go ahead and attempt one of them and that should convey an approach.

I am going to use pseudocode instead of C syntax in an effort to keep it simple.

Before I dive in, I want to comment on a few things that I have noticed thus far.

-The 9.95 for 10 hours plus $2 for each hour should all be stored in globals somewhere in case they need to be changed.

PKGA_BASE_RT = 9.95
PKGA_BASE_HRS = 10
PKGA_EXTRA_HR_RT = 2

I would do this for each of the three packages to some extent. It will impress (the teacher) and it is considered good practice.

Let's begin (pseudocode remember)

Code:

PKGA_BASE_RT = 9.95
PKGA_BASE_HRS = 10
PKGA_EXTRA_HR_RT = 2
NP_DSCT_PCNT = .20

/* "hours_used" will be the number of hours the job took
     Calculate total for package A (w/o discount)
     First see if hours is less than PKG_A_BASE_HRS */

if( hours_used < PKGA_BASE_HRS )
     packageA_subTotal = PKGA_BASE_RT
else
     packageA_subTotal = PACKAGE_A_BASE_RATE + (( hours_used - PKGA_BASE_HRS ) * PKGA_EXTRA_HR_RT )


/* Calculate discount if there is one and figure it into grand total
    "discount" a boolean value if the box is checked or not */

if( discount )
    packageA_Total = packageA_subTotal - ( packageA_subTotal * NP_DSCT_PCNT )
else
    packageA_Total = packageA_subTotal

return packageA_Total



There are a couple of ways to go about doing this. That is just a basic idea of one of them applied to package A. It is pseudocode, so it might be messy, but it should get you started.

-Weaver

Edit: Struggled to make look decent in "code" bbcode
 
Back to top
thankins
PostPosted: Thu Sep 18, 2003 5:04 pm Reply with quote

PRO Level 2
 
 


Joined: 05 Mar 2003
Posts: 40
Location: USA
Thanks Weaver, that helped a little. I think I got the global variable in there now but still a little lost on the whole radio button selection calculate thing.


Here are my class variable:
Code:
The following class-level constants are used
    'to calculate the discounts
    Dim packageBaseRateA As Double = 9.95          'Package A Base Rate
    Dim packageBaseRateB As Double = 14.95         'Package B Base Rate
    Dim packageBaseRateC As Double = 19.95         'Package C Base Rate
    Dim pakABaseHrs As Double = 10                 'Package A Hours
    Dim pakBBaseHrs As Double = 20                 'Package B Hours
    Dim pakAExtraHours As Double = 2.0             'Package A Extra Hour Rate
    Dim pakBExtraHours As Double = 1.0             'Package B Extra Hour Rate
    Dim nonProfit As Double = 0.2                  'Non Profit Org Discount
             




and Here is my btnCalc_Click so far.
Code:
  Private Sub btbCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbCalc.Click
        'Claculates and displays the price for internet usage


        'Declares local variable
        Dim packageA As Double     'Package A
        Dim pacakgeB As Double     'Package B
        Dim pacakgeC As Double     'Package C
        Dim hoursUsed As Double    'Hours used by consumer

       
        'Validate the number of Hours
        If Val(txtHours.Text) < 1 Or Val(txtHours.Text) > 744 Then
            MessageBox.Show("Enter a vlaue in the range of 1-744 for " & _
                            "hours of usage.", "Input Error")



        Else
            If (hoursUsed < pakABaseHrs) Then
                packageA = 9.95
            Else
                packageA = packageA + ((hoursUsed - pakABaseHrs) * pakAExtraHours)





            End If



Hope all that makes sense. I set it up like you said but how do I get the radiobuttons in so that the program sees that radio button Package A is selected and calculates that. I believe that the hoursused If statement is correct I jut dont know how to add in the radio buttons [/code]
 
Back to top
Weaver
PostPosted: Thu Sep 18, 2003 5:44 pm Reply with quote

PROfessional Member
 
 


Joined: 18 Jun 2002
Posts: 2587
Location: /home/weaver/
Like I said before, I have never even touched Visual Basic. Thus, I haven't the first idea how to add in radio buttons. If you are taking this at a school your text should cover topics such as this.

Your problem now seems to be a language dependent problem (radio buttons), not a procedural one. Now that you are familiar with the procedure consult other sources to uncover the mystery of those radio buttons (or checkboxes).

-Weaver
 
Back to top
odayict
PostPosted: Tue Mar 02, 2004 1:27 am Reply with quote

Banned
 
 


Joined: 26 Feb 2004
Posts: 429
Location: Phoenix, Arizona
when i made programs that are directory related, it would not work because I dont know the full path.
for example If i want to create a text files at C:\Documents and Settings\"Current User"\Desktop\a.txt
how do i do it?
I dont know whats the path
help needed ASAP
people are relying on me
 
Back to top
Weaver
PostPosted: Tue Mar 02, 2004 11:34 am Reply with quote

PROfessional Member
 
 


Joined: 18 Jun 2002
Posts: 2587
Location: /home/weaver/
odayict wrote:
when i made programs that are directory related, it would not work because I dont know the full path.
for example If i want to create a text files at C:\Documents and Settings\"Current User"\Desktop\a.txt
how do i do it?
I dont know whats the path
help needed ASAP
people are relying on me


You should be able to use some VB/Windows API to detect the environment variable that says which user is logged in. Then just replace the user with "Current User".

If you open up a 'cmd' window and type 'set' you can see the list of current environmental variables. The variable you are looking to extract is 'USERNAME' or 'USERPROFILE', whichever you would feel more comfortable with. I would recommend using 'USERPROFILE'. You will have to use a VB/Windows API to ge able to grab this information from within your VB code.

Sounds about right to me. Remember that I haven't ever touched VB so don't trust me.

-Weaver
 
Back to top
Back to top
Index >> Webmaster Domain & Code Room >> Visual Basic Help

Goto page 1, 2  Next

Page 1 of 2

 


Tired of the Ads? Registered users have 80% less adverts.