4 Replies - 5970 Views - Last Post: 11 November 2010 - 03:06 PM Rate Topic: -----

#1 Skillzilog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 75
  • Joined: 25-September 10

Getting the highest and lowest number [if else statement]

Posted 09 November 2010 - 06:27 AM

        Dim MyVal As Integer
        Dim MyVal2 As Integer

        MyVal = Val(TextBox4.Text)
        MyVal2 = Val(TextBox5.Text)

        If Val(TextBox1.Text) > MyVal Then
            MyVal = Val(TextBox1.Text)
        ElseIf Val(TextBox1.Text) < MyVal2 Then
            MyVal2 = Val(TextBox1.Text)
        End If

        If Val(TextBox2.Text) > MyVal Then
            MyVal = Val(TextBox2.Text)
        ElseIf Val(TextBox2.Text) < MyVal2 Then
            MyVal2 = Val(TextBox2.Text)
        End If

        TextBox4.Text = MyVal
        TextBox5.Text = MyVal2

        Label5.Text = TextBox1.Text
        Label6.Text = TextBox2.Text
        Label7.Text = TextBox3.Text


i dont know how to use array thats why i used if else statement, but it cant find the lowest number, only the highest

Is This A Good Question/Topic? 0
  • +

Replies To: Getting the highest and lowest number [if else statement]

#2 Amrykid  Icon User is offline

  • 4+1=Moo
  • member icon

Reputation: 148
  • View blog
  • Posts: 1,589
  • Joined: 16-December 08

Re: Getting the highest and lowest number [if else statement]

Posted 09 November 2010 - 07:09 AM

What are the values of the textboxes?
Was This Post Helpful? 1
  • +
  • -

#3 Skillzilog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 75
  • Joined: 25-September 10

Re: Getting the highest and lowest number [if else statement]

Posted 09 November 2010 - 07:30 AM

sir the textboxes are blank, the user will input on the textboxes then it will determine what is the HIGHEST AND LOWEST number
Was This Post Helpful? 0
  • +
  • -

#4 Skillzilog  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 75
  • Joined: 25-September 10

Re: Getting the highest and lowest number [if else statement]

Posted 09 November 2010 - 05:38 PM

i dont know why this isnt working, it gets the highest number, but it doesnt get the lowest,


If Val(TextBox2.Text) > MyVal Then
MyVal = Val(TextBox2.Text)
ElseIf Val(TextBox2.Text) < MyVal2 Then
	    MyVal2 = Val(TextBox2.Text)

End If
Was This Post Helpful? 0
  • +
  • -

#5 acouch  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 19-June 09

Re: Getting the highest and lowest number [if else statement]

Posted 11 November 2010 - 03:06 PM

You are using ELSEIF which will only execute if the first IF evaluates to false. Try making this it's own IF statement.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1