# How Do I Check if two strings are within a range of eachother?

Page 1 of 1

## 2 Replies - 1295 Views - Last Post: 25 December 2009 - 04:12 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=147008&amp;s=a78ea658099e1ceb16b72f308a18f296&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 zukeru

Reputation: 2
• Posts: 163
• Joined: 25-December 09

# How Do I Check if two strings are within a range of eachother?

Posted 25 December 2009 - 10:46 AM

Hey if anyone could help that would be sweet.

First Thing I need Help With.
I need to take six altitudes altitude1 and altitude2 and check to see if they are with in a value of 250 of each other. Then if there are any that are within 250 of each other, to make them turn red.

Second thing is:

I need to take 6 altitudes, and arrange them. I have them in panels and I have 6 empty panels as place holders for .location value however I need to know how to look at 6 values and say arrange these values accordingly highest number this place lowest number this place etc.

I have looked everywhere on the internet and maybe im just retarded when it comes to math in vb.net. If anyone could help that would be seet.

Is This A Good Question/Topic? 0

## Replies To: How Do I Check if two strings are within a range of eachother?

### #2 Core

• using System.Linq;

Reputation: 784
• Posts: 5,101
• Joined: 08-December 08

## Re: How Do I Check if two strings are within a range of eachother?

Posted 25 December 2009 - 11:28 AM

For the first task, you have to find which altitude is bigger first. Convert the strings to an integer and compare them. Then, calculate the difference. Something like this:

```Dim altitudeA As Integer = 0
Dim altitudeB As Integer = 0
Dim diffference As Integer = 0
Dim aIsBigger As Boolean = False

altitudeA = Convert.ToInt32 (textBox1.Text)
altitudeB = Convert.ToInt32 (textBox2.Text)

aIsBigger = altitudeA > altitudeB

If aIsBigger Then
difference = altitudeA - altitudeB
Else
difference = altitudeB - altitudeA
End If

If difference > 250 Then
textBox1.BackgroundColor = Color.Red
textBox2.BackgroundColor = Color.Red
End If

```

As for arrangements, here is when it comes to sorting in arrays. You have the create an array (of Integer or whatever is the numeric data type you have) and sort it. Now, there are several ways to sort a unidimensional array (and that is exactly what you have here). You can read more about it here. When you sort it, you can assign the values to the according panel elements.

### #3 zukeru

Reputation: 2
• Posts: 163
• Joined: 25-December 09

## Re: How Do I Check if two strings are within a range of eachother?

Posted 25 December 2009 - 04:12 PM

Thanks For that. That will come in handy im going to try it out tonight. thanks man you don't know how much that helps me sorry for the noob question i have never taken a class i have only been dabbling i will post my tpc pack tutorials and also how to search a string for specific designation and then take the next 5 charecters of the string and only display thos that took me fing forever to figure out. anyways thanks for the help once again just something I didnt think about lol cause i know all the commands just didnt think about it like that im sure i will run in to some issues but thanks.