?
Solved

Getting negitive Number

Posted on 2004-10-25
1
Medium Priority
?
190 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
Comment
Question by:Jedidia
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 12400073
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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…

592 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