#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Compare Strings

Is there an easy way (using VBA) to compare the values of 3 text
boxes? I want to make sure that the values of all 3 text boxes are
NOT the same. I tried StrComp, but that only compares 2 string. I
assumed there would be an easy way without having nested if's....


Thanks,
DK
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Compare Strings

Hi,

You can try this:

Me.TextBox1 = Me.TextBox2 And Me.TextBox1 = Me.TextBox3


If this helps, please check the Yes button

--
Thanks,
Shane Devenshire


"dksaluki" wrote:

Is there an easy way (using VBA) to compare the values of 3 text
boxes? I want to make sure that the values of all 3 text boxes are
NOT the same. I tried StrComp, but that only compares 2 string. I
assumed there would be an easy way without having nested if's....


Thanks,
DK

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Compare Strings

On Sat, 18 Oct 2008 06:35:31 -0700 (PDT), dksaluki wrote:

Is there an easy way (using VBA) to compare the values of 3 text
boxes? I want to make sure that the values of all 3 text boxes are
NOT the same. I tried StrComp, but that only compares 2 string. I
assumed there would be an easy way without having nested if's....


Thanks,
DK



Perhaps this example will help:

====================
Option Explicit
'set comparison type to either Text or Binary
Option Compare Text
Sub Comp3()
Const s1 As String = "def"
Const s2 As String = "abc"
Const s3 As String = "ABC"


Select Case _
(s1 = s2) + (s1 = s3) + (s2 = s3)
Case Is = 0
Debug.Print "All Different"
Case Is = -1
Debug.Print "One match"
Case Is = -3
Debug.Print "all the same"
End Select
==========================
--ron
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 806
Default Compare Strings

Hmm,

Shouldn't ist be more like
Me.TextBox1 = Me.TextBox2 Or Me.TextBox1 = Me.TextBox3 Or Me.TextBox2
= Me.TextBox3
?

Regards,
Bernd


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Compare Strings

I'll try that! thank you all very much

DK
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare two strings andy62 Excel Worksheet Functions 8 September 6th 06 02:14 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
Compare the strings yangyh Excel Discussion (Misc queries) 3 September 8th 05 04:45 AM
How can I count strings within strings Paul W Excel Worksheet Functions 4 June 14th 05 12:39 PM
Compare cells/columns and highlight matching text strings luxbelle Excel Worksheet Functions 1 February 25th 05 06:34 PM


All times are GMT +1. The time now is 08:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"