locked
Look at my code please RRS feed

  • Question

  • I am writing a program to select the category of a hurricane by inputing the number in a text box and using a button to determine the outcome. But no matter what number i put in it just returns category two hurricane

    Option Strict On

    Public

     

     

    Class Form1

     

     

    Private Sub Btndetermine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndetermine.Click

     

     

    Dim speed As Double

     

     

    Select Case speed

     

     

    Case Is >= 74 - 95

    Txtoutput.Text =

     

    "Category One Hurricane"

     

     

    Case Is >= 96 - 110

    Txtoutput.Text =

     

    " Category Two Hurricane"

     

     

    Case Is >= 111 - 130

    Txtoutput.Text =

     

    "Category Three Hurricane"

     

     

    Case Is >= 131 - 155

    Txtoutput.Text =

     

    " Category Four Hurricane "

     

     

    Case Is > 155

    Txtoutput.Text =

     

    " Category Five Hurricane "

     

     

    End Select

     

     

    End Sub

    End

     

     

    Class

    What am i missing?

    Friday, November 19, 2010 12:23 AM

Answers

  • Note also that your Case expressions are wrong.  For instance:

    Case Is >= 131 - 155

    will be executed for values less than or equal to (131 - 155) or less than or equal to 24.  I think you mean

    Case ((Speed <= 155) And (Speed > 131))

    • Marked as answer by jonnyrotten Sunday, November 21, 2010 5:40 AM
    Friday, November 19, 2010 1:08 AM

All replies

  • Your never tell the app what the speed is ie: Dim Speed As Double = 200
    Friday, November 19, 2010 12:32 AM
  • Note also that your Case expressions are wrong.  For instance:

    Case Is >= 131 - 155

    will be executed for values less than or equal to (131 - 155) or less than or equal to 24.  I think you mean

    Case ((Speed <= 155) And (Speed > 131))

    • Marked as answer by jonnyrotten Sunday, November 21, 2010 5:40 AM
    Friday, November 19, 2010 1:08 AM
  • Jonnyrotten / biggBenn

    4 identical threads !!

    • Proposed as answer by Cor Ligthert Friday, November 19, 2010 6:46 AM
    • Unproposed as answer by jonnyrotten Sunday, November 21, 2010 5:40 AM
    • Proposed as answer by Renee Culver Sunday, November 21, 2010 6:26 AM
    Friday, November 19, 2010 2:32 AM
  • Thats my bad I am having trouble with my new computer and the postings were not showing up when I posted them. i thought it was my profile I don't know much about computers as you can tell
    Sunday, November 21, 2010 5:51 AM
  • Im sorry johny. It was undeletable almost instantly.

    Renee

    Sunday, November 21, 2010 6:29 AM