to:Bob Phillips- don't answer if u don't know what ur talking about!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

String "cat" does not = "atc" in a direct string to string comparison. I need a function/routine that returns true.
 
Does

Access = aces

What is your definition of equal.

--
Regards,
Tom Ogilvy

chris said:
String "cat" does not = "atc" in a direct string to string comparison. I
need a function/routine that returns true.
 
Function returnTrue() As Boolean
returnTrue = True
End Function

I may have misunderstood the question !
 
I need a function/routine that returns true.
Function returnTrue() As Boolean
returnTrue = True
End Function

LOL. Thanks.

Best wishes Harald
Followup to newsgroup only please
 
If you re-read your question you may find it was at all very precise. Even
if it would have been there is no reason at all to start a new thread
specifically to publicly insult someone who tried to help.

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel

chris said:
String "cat" does not = "atc" in a direct string to string comparison. I
need a function/routine that returns true.
 
You have a charming attitude that I am sure will endear you to all and will
ensure immediate help when ever you request it again. But for me, your name
is on the bin-list.Goodbye!


chris said:
String "cat" does not = "atc" in a direct string to string comparison. I
need a function/routine that returns true.
 
<it was at all very> should of course have been <it was NOT at all very>

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel
 
chris said:
String "cat" does not = "atc" in a direct string to string comparison. I
need a function/routine that returns true.


do somethng like this

Public Function HasSameLetters(str1, str2) As Boolean

Dim i As Integer, cnt As Integer, temp As String

' First check strings are same same length
If Len(str1) <> Len(str2) Then
' Character not found
HasSameLetters = False
Exit Function
End If

temp = str2

HasSameLetters = True
'Go through each character in string
For cnt = 1 To Len(str1)
' Use instr function to look for character
i = InStr(1, temp, Mid(str1, cnt, 1))

If i = 0 Then
' Character not found
HasSameLetters = False
Exit For
ElseIf i = 1 Then
' catch situation where i = 1
temp = Mid(temp, 2, Len(temp))
Else
'strip character from second string
temp = Mid(temp, i - 1, 1) & Mid(temp, i + 1, Len(temp))
End If


Next cnt

'If you get here both strings have same letters

End Function

Keith
 
Hi,

Check that following code. I think that's the code you want.

Function CompareString(String1 As String, string2 As String) As Boolean
Dim Set1
Dim Set2
CompareString = True
If Len(String1) <> Len(string2) Then
CompareString = False
Exit Function
End If

ReDim Set1(Len(String1))
ReDim Set2(Len(string2))
For i = 1 To Len(String1)
Set1(i) = Mid(String1, i, 1)
Set2(i) = Mid(string2, i, 1)
Next
Index = Len(String1)
Set1 = SortArray(Set1)
Set2 = SortArray(Set2)
For i = 1 To UBound(Set1)
If Set1(i) <> Set2(i) Then
CompareString = False
Exit Function
End If
Next i
End Function

Private Function SortArray(sArray As Variant) As Variant
Dim tArray As Variant
Dim counter As Integer
tArray = sArray
Index = UBound(tArray)
For counter = 1 To (Index)
Smallest = counter
For Counter2 = (counter + 1) To Index
If tArray(Smallest) > tArray(Counter2) Then Smallest = Counter2
Next Counter2
Temp = tArray(counter)
tArray(counter) = tArray(Smallest)
tArray(Smallest) = Temp
Next counter
SortArray = tArray
End Function
 

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

Back
Top