Compare Strings

D

dksaluki

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
 
S

ShaneDevenshire

Hi,

You can try this:

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


If this helps, please check the Yes button
 
R

Ron Rosenfeld

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
 
B

Bernd P

Hmm,

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

Regards,
Bernd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top