Solved

Getting negitive Number

Posted on 2004-10-25
187 Views
Last Modified: 2012-05-05
Can somoen please explain to me why I would get a negative number if I enter 355 into the textbox.

---------------------------------------------------------
Private mdblHouseSqFt As Double = 0
Select Case txtHomeSqFt.Text
            Case 0 To 1000
                mdblHouseSqFt = txtHomeSqFt.Text * 0.1
            Case 1001 To 2000
                mdblHouseSqFt = ((txtHomeSqFt.Text - 1000) * 0.11) + 100
            Case 2001 To 3000
                mdblHouseSqFt = ((txtHomeSqFt.Text - 2000) * 0.12) + 210
            Case 3001 To 4000
                mdblHouseSqFt = ((txtHomeSqFt.Text - 3000) * 0.13) + 330
            Case Else
                mdblHouseSqFt = ((txtHomeSqFt.Text - 4000) * 0.14) + 460
        End Select
txtTaxOnHome.Text = mdblHouseSqFt
-----------------------------------------------------------

Thanks.
0
Question by:Jedidia
    1 Comment
     
    LVL 85

    Accepted Solution

    by:
    Because you are using a string as the case parameter but the values in your case statements are numbers so it is jumping to the Case Else all the time.

    Change

        Select Case txtHomeSqFt.Text

    to

        Select Case CInt(txtHomeSqFt.Text)

    ~IM
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video discusses moving either the default database or any database to a new volume.

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now