Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find TextBoxes with Equal Values

Status
Not open for further replies.

Fletch12

IS-IT--Management
Aug 13, 2002
140
0
0
US
I have four textboxes on a single form. How can I search the values in these textboxes to determine which contain equal values to the other?

So textbox1 can equal textbox3 and textbox4, but not textbox2. Or textbox1 can equal textbox2 and textbox3 can equal textbox4, but textbox1 not equal textbox3. Or all textboxes can contain the same values. Or none of the textboxes may contain the same values. And so on. I know I can write a lot of if-else statements but seems like there would be an easier way to do this.
 
First, I would suggest showing what you have so far. Second, what is the end result of this? What do you want to do once you find the matches? This could make a big difference on what you might want to do.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
I would think someone a lot smarter than me could come up with a recursive function based on an array or small table of the values that need to be compared that would return the matches like: 1=3, 1=4, 2=3, etc. If it's recursive it could handle a fairly lengthy list, but you wouldn't want to get too carried away with a large number of values.

Auguy
Sylvania/Toledo Ohio
 

I think the problem here is that Fletch12 never stated what should happen if textbox1 = textbox3

Should they start flashing? Change color? Display a message?

Have fun.

---- Andy
 



...and does this analysis occur on some particular event?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Seems pretty simple to me.

Code:
If Textbox1.Text = Textbox2.Text
Endif

If Textbox1.Text = Textbox3.Text
Endif

If Textbox1.Text = Textbox4.Text
Endif

If Textbox2.Text = Textbox3.Text
Endif

If Textbox2.Text = Textbox4.Text
Endif

If Textbox3.Text = Textbox4.Text
Endif

Six statements. Is that a lot?



 
tcsbiz, your six statements might do the trick, but it is not very extensible. What happens if you need to add another textbox? The permutations will quickly spin out of control.

A much better approach is to create a procedure/method/code that will do all this without having to refer to each control by name.

And that is why the questions have been posed to the original poster as to what should happen if two (or more text bxoes) are equal.

More info is needed to fully help solve the particular issue here.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top