I would like to test two strings to see if a space has been added.
str1 "100S LWB CH5S"
str2 "100 S LWB CH5S"
The string is essentially the same text but only had a space added at some part.
Is that possible to test for
ie determine if space added and if added add the space temporarily to str1 and then do a compare to make sure they are equal strings?
Microsoft Access
Last Comment
JAMcDo
8/22/2022 - Mon
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Well, you can use StrComp to see if the are equal or note:
example:
strcomp("100S LWB CH5S","100 S LWB CH5S")
returns 1 because they are not equal
StrComp returns :
string1 is less than string2 -1
string1 is equal to string2 0
string1 is greater than string2 1
string1 or string2 is Null Null
mx
PeterBaileyUk
ASKER
and is it easy to find where the space belongs in field 1?
i am thinking maybe checking each character until they dont match and at that point string2(position string1 +1) should be a space and if it is then add a space at string1(position)
PeterBaileyUk
ASKER
or another thought find current space positions in string2
string 1 positions should correspond to string 2 bar 1 and thats my insertion point on string 1
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
"or another thought find current space positions in string2"
You can use the InStr() function to find the first occurrence of a Space (or any character)
InStr(1,SearchString, SearchingFor) returns the first position fo Searching For
example:
strcomp("100S LWB CH5S","100 S LWB CH5S")
returns 1 because they are not equal
StrComp returns :
string1 is less than string2 -1
string1 is equal to string2 0
string1 is greater than string2 1
string1 or string2 is Null Null
mx