I am having trouble with a function in vb can anyone give me a suggestion?

I am trying to calculate a cable bill of a residential customer and a business customer, when the customer checks the list box of the channels and the connections I need it to add it up. I have edited the code. Does my logic make sense?
for residential customers it is 4.50 processing,30 basic service and 5 per channel
so is the logic processing+basicservice *premium
Public Class Main
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
If Data_Validated_ok() = False Then Exit Sub
Dim premiumChannels As Integer = lstPremium.SelectedIndex
Dim Connections As Integer = lstConnections.SelectedIndex
Dim totalDue As Decimal
If radResidential.Checked Then
totalDue = CalcResidentialTotalDue(premiumChannels, Connections)
lblTotal.Text = totalDue.ToString("C2")
Else
totalDue = CalcBusinesssTotalDue(premiumChannels, Connections)
lblTotal.Text = totalDue.ToString("C2")
End If
End Sub
' make a function to calculate residential customers
Private Function CalcResidentialTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
) As Decimal
Const ResidentialProcessing As Decimal = 4.5D
Const ResidentialBasic As Integer = 30
Const ResidentialPremium As Integer = 5
Return ResidentialProcessing + ResidentialBasic + ResidentialPremium * premiumChannels
End Function
' make a function to calculate business customers
Private Function CalcBusinesssTotalDue(ByVal premiumChannels As Decimal, ByVal connections As Decimal
) As Decimal
Const BusinessProcessing As Decimal = CDec(16.5)
Const BusinessBasic As Integer = 80
Const BusinessPremiumchannels As Integer = 50
Return BusinessProcessing + BusinessBasic + BusinessPremiumchannels * premiumChannels
End Function
here is  a pic of my listboxes
[IMG]http://i57.tinypic.com/muepug.png[/IMG]
http://i57.tinypic.com/muepug.png

The statement below is wrong in both functions.  You are passing the variable "connections" in the function parameter list and not using the variable.  I thing in the statement below you need to change connections to something else.
connections = Convert.ToDecimal(lstConnections.SelectedItem)
Here are the two parameter lists
1)    Private
Function calcResidentialTotal(ByVal connections
As Decimal,
ByVal premium As
Decimal)
As Decimal
2)   Private
Function calcBusinessTotal(ByVal connections
As Decimal,
ByVal premium As
Decimal)
As Decimal
jdweng

Similar Messages

  • Having trouble with Hyperlinks in Indesign CS6 Can Anyone Help?

    I'm creating an ebook. I've created my hyperlinks - like I always do - Hyperlink destination for Chapter Number and New Hyperlink in the Table of Contents. It works when I check it in Indesign but when I export the epub file and open it in Digital Editions or Calibre there is no evidence of a hyperlink. As if I didn't create any. Tried everything.
    Could it be something in the Microsoft Word doc. I imported into Indesign?
    Appreciate your help.

    Ask in the ID forum.
    Mylenium

  • I am having trouble with my iphoto. I can't print from there or do much of anything. When i double click on an event it doesnt open. Any suggestions?

    I am having trouble with my iphoto. I can't print from there or do much of anything. When i double click on an event it doesnt open. Any suggestions?

    ~/Library/Preferences/com.apple.iPhoto.plist
    ~ = your home folder
    Here's a picture
    Chris

  • Having trouble with syncing my phone ? can you help me please ?

    having trouble with syncing my phone ? can you help me please ?

    Is iTunes giving you a error code?? Exactly what problem are you having?

  • I am having trouble downloading my movies purchase.  can anyone help me?

    I am having trouble downloading my movie purchase.  Can anyone help me?

    I am using a new Apple TV streaming box. I cannot seem to get any itunes movies to completely download. If they do completely download, it often takes a day or more. Even when the download is apparently completed, ATV will often re-authorize the movie purchase...and the download process begins again. That is about the time I send emails and get refunds. NETFLIZ works beaitifully - fast, easy to use, NEVER a problem. I use a MAC, iPad too but have not synced either with ATV.
    Am I doing something wrong? This is incredibly frustrating for my family!!!!

  • I down loaded ios7 and now I'm having trouble with my audio on Skype, does anyone knows how to fix it? Please help!

    WWith the new ios7, I became frustrated in using my iPad3..I'm using Skype as my main communications with my love ones back home,now it seems that ios7 doesn't help me a lot for I'm having trouble with my audio communication coz my family can't hear anything from me.. My skype doesn't have any options or settings that I can check with to see if I can fix it...I need help...please if any of u knows how to fix it..I would greatly appreciate it...

    You can try removing app then reinstalling. If that doesn't work
    Try a Restart. 
    Press and hold the Sleep/Wake button for a few seconds until the red "slide to power off" slider appears, and then slide the slider. Press and hold the Sleep/Wake button until the Apple logo appears.
     Resetting your settings
    You can also try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your device settings again.... All of the settings in the settings app will have to be re-entered. You won't lose any data, but it takes time to enter all of the settings again.
    Resetting your device
    Press and hold the Sleep/Wake button and the Home button together for at least ten seconds, until the Apple logo appears. Apple recommends this only if you are unable to restart it.
    Or if this doesn't work and nobody else on the blog doesn't have a better idea you can contact Apple. 
    Here is a link to their contacts with most of the information below. 
    http://www.apple.com/contact/

  • Having trouble with put_line function in block statement..

    Am a student, and the request does not appear to be in my book anywhere... Nothing on put_line, or block statements that I can see..
    Need to write a block which will bring back via put_line for department 110: the department_id (departments table), the department_name (departments table), and the city in which the department is located (which must be pulled from locations table... can be joined by department_id). I can write the select statement with join, just not sure how to turn it into a block with put_line function..
    any advice appreciated.. Thanks.

    Hi,
    You need to format your code, so that it's easy to see what statements are in each section (DECLARE, BEGIN, etc.).
    The compiler doesn't care about this, but it will help anyone who tries to read your code, including yourself.
    Type {code} before and after formatted sections when posting messages on this site.
    All statements, including each individual variable declaration) end with a semicolon.
    If a query will return no more than one row, you can capture the results using an INTO-clause, right after the SELECT-clause. For every column in the SELECT-clause, there will be one variable in the INTO-clause.
    Lists, including lists of table names in a query's FROM-clause, are delimited by commas.
    In a query's FROM-clause, the real name of the table comes first, optionally followed by the alias you're using in the query.
    I think this is what you're trying to do:
    SET   SERVEROUTPUT  ON  SIZE 50000
    Declare
        dep_id    NUMBER;
        Dep_string VarChar (100);
    Begin
        select  d.department_id, d.department_name -- , l.city
          into  dep_id,          dep_string
          from  departments  d
             ,  locations    l
          where d.location_id = l.location_id
            and d.location_id = 110;
        DBMS_OUTPUT.PUT_LINE (Dep_string);
    END;
    /No one should ever have this many errors at one time. Write code in much smaller increments, and test after each one. For example, you know you'll be using dbms_output.put_line, so start with something like:
    SET   SERVEROUTPUT  ON  SIZE 50000
    BEGIN
        dbms_output.put_line ('Hello, world!');
    END;You may have problems if you forget semicolons, or SET SERVEROUTPUT. Solve those before you go any further.
    Once the program above is working, add a little (and I mean a little) to it.
    For example, you know you'll be printing a varibale, not a literal, so change it to a variable:
    SET   SERVEROUTPUT  ON  SIZE 50000
    DECLARE
        dep_string  VARCHAR2 (100) := 'Hello, world!';
    BEGIN
        dbms_output.put_line (dep_string);
    END;And so on.
    Edited by: Frank Kulash on Dec 15, 2008 12:36 PM

  • I'm having trouble with my iMessages registration. Has anyone had any problems after they downloaded the mountain lion King with that iMessages because mine is not linking to the computer and my phone

    Is anyone else having trouble after thy downloaded Mountain lion x with iMessages mine isnt linking to my computer because it keeps saying i have a  registration error. Has anyone else had this problem or know how to fix it

    HI,
    People who have had computer that has had the Logic/motherboard replaced during repair or refurbishment that has not has the Mac Serial Number Flashed to the board have found that iMessage in particular have not been able to "register".
    A current purchase of Mountain Lion will tend to give you the latest version which as of Thursday (12 th Mar) is OS X 10.8.3
    You can use System Information to find if the Serial Number is there as it appears under the Hardware section.
    If it is missing you need to get to an Apple Store or Apple Authorised Service Provider who can flash the info to the board.
    10:46 PM      Saturday; March 16, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • I am having trouble with texting out.  I can receive but cannot send.  Any advice?  Carrier is ok.

    Hi!  I am having trouble texting out.  I can receive texts, but can't send any longer.  All settings are ok and carrier is ok.  Any advice?

    Hi text is a network service contact your network service provider . Cheers Brian

  • Grapher having trouble with trig functions

    Well I thought that I could make some cool visuals for my math class by using grapher instead of just making charts and graphs in Excel on my pc, but no dice with that idea. I created all the different variables (and how they related to x, ie x^2*(5-x6)/x=m) and it was pretty cool how it would all come together and I could use those variables in other equations instead of writing it all out (stuff like y=4x^m-m/5). (Those are examples, not anything I used)
    Everything seemed fine until I tried to use a cosine function in one of the equations. It seemed really intuitive and recognized cos as cosine and not the variables c, o, and s multiplied, so I thought "great!" Then when I entered it the graph didn't appear anything like it should have. It gave me a Richter scale instead of a slightly curved line. I spent about half an hour trying to find my own error but then realized maybe there was something wrong with the program. I tried just plain old cos(x) and found that it was completely off. Instead of traveling from 0,1 to 180,-1 like it should have, it went from 0,1 to 3.1475,-1. This was way off so I tried a sine function and that did the same exact thing (having a period of roughly 6.295 instead of 360!). These functions were way off, and I'm using an intel macbook from my school (with 10.5), so I thought maybe someone changed the settings, so I tried them them on my aunts g4 macmini (10.4.11 I think) and it gave me the same problem!
    Anyway what's wrong with the trig functions for Grapher and how can I fix them?

    Emzz, I'm running 10.5.5 (Intel) and Grapher v2.0. My version of Grapher supports changing Trigonometric Mode, so the absence of this option seems to have nothing to do with Leopard.
    But let's do some Math now. As you surely know the cosine has (besides others) a root at 90 Degrees in the unit circle. Now let f : (angle in Degrees) -> (length of the corresponding arc of the unit circle) be a mapping. For 90 Degrees f yields 0.5*Pi. That means cosine has a root at 0.5*Pi in Radian unit.
    Now, if you swith Grapher's Trigonometric Mode from Degrees to Radian, cosine will no longer have a root at 90 but at approximately 1.57. Hope that explains a bit...
    By the way, Radian is the standard unit of angular measurement when it comes to trigonometric functions. For more details about Radian see [this article at Wikipedia|http://en.wikipedia.org/wiki/Radian] (click the link to be redirected).
    I suggest you close this topic because, as you already noted yourself, your initial question is answered.
    Good computing.
    floba
    (MN576)
    Message was edited by: floba

  • TS1702 Anyone having trouble with My Brushes vendor?  Can't contact the support email they give us?

    I got the My Brushes App for iPad 2 - have questions on how to use it but the support email address the vendor gives doesn't work??

    Well, it certainly could be a factor. Many Newstand apps are multimedia, and contain sizable files. However, once the download is complete, everything needed to view the issue is generally there, at least in my experience (mostly with NatGeo). Its possible US Weekly is different and designed to access live internet content.
    I do see from the App store that this gets quite a few negative reveiws for a variety of reasons.

  • TS3694 having trouble with my ipad 3 restoring...gives me code 40...unknown eroor

    please help

    iPad: Basic troubleshooting
    http://support.apple.com/kb/TS3274
    Update and restore alert messages on iPhone, iPad, and iPod touch
    http://www.buybuyla.com/tech/view/012953a0d412000e.shtml
    iOS: Resolving update and restore alert messages
    http://support.apple.com/kb/TS1275
    iPad: Unable to update or restore
    http://support.apple.com/kb/ht4097
    iTunes: Specific update-and-restore error messages and advanced troubleshooting
    http://support.apple.com/kb/TS3694
    If you can’t update or restore your iOS device
    http://support.apple.com/kb/ht1808
     Cheers, Tom

  • It appears that FF3.6.10 is having problems with Silverlight on NetFlix. Can anyone confirm that they are unable to play movies?

    Intel Mac OSX 10.5.8
    FF 3.6.10
    Silverlight (lastest)

    I'm having problems streaming movies from Netflix so I called them. They told me if I was dissatisfied, I could cancel my service with them. I guess this is their new customer service policy.

  • HT201210 Having problems with restoring my iphone 3g can anyone help?

    When I am trying to restore my iPhone 3g iTunes first states that an iphone has been detected in 'recovery mode' so I click ok, then it starts restoring the iPhone and before it is complete a pop-up box comes up and says unknown error (1015)
    Can anybody help??

    That error almost always indicates your phone was jailbroken.
    If that's the case, you can't get help here. Try google or the hacking community.
    If you are absolutely positive that your phone was not jailbroken or hacked, and that you are not attempting to downgrade iOS, then you have a hardware failure.

  • I am having problems with iChat after installing Lion, can anyone help?

    I installed Lion this week after I installed everything seemed to be working great. However, if I open iChat and then log in and log out it will not let me log back into iChat

    Try logging on to AIM on port 443 rather than port 5190.
    Go to IChat in the menu bar > Preferences > Accounts.
    Log out of AIM and then use the Server Settings tab
    Set the port to 443(press return/enter(you might have to tick and untick SSL for 443 to stick)).
    Log back in again.

Maybe you are looking for