# Getting the highest and lowest number [if else statement]

Page 1 of 1

## 4 Replies - 6715 Views - Last Post: 11 November 2010 - 03:06 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=199139&amp;s=c302734730ee8ce32f2294537fd8599f&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Skillzilog

Reputation: 0
• 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

• 4+1=Moo

Reputation: 150
• 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?

### #3 Skillzilog

Reputation: 0
• 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

### #4 Skillzilog

Reputation: 0
• 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

### #5 acouch

Reputation: 1
• 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.