Find replace function...

Find replace function...

Anonymous
Not applicable
599 Views
3 Replies
Message 1 of 4

Find replace function...

Anonymous
Not applicable
I'm trying to write a find and replace function that finds Text or MText fractions and replaces them with our bigfont. The strings that it needs to find are as follows:

1/16 --> [1
1/8 --> [2
3/16 --> [3
1/4 --> [4
....
15/16 --> [T
------

Example:

Finds and changes the string:
31'-1 5/8" (W16x31 x 31'-0 5/8")

to the string:
31'-1]0" (W16x31 x 31'-0[0")

Doesn't change the string:
Don't Change / This to anything...

Thanks,
MSR


The function needs to work VERY quickly as it will be run as part of an add on a batch process.

Any help will be much appreciated.
0 Likes
600 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
What code do you have allready?



schreef in bericht news:[email protected]...
I'm trying to write a find and replace function that finds Text or MText
fractions and replaces them with our bigfont. The strings that it needs to
find are as follows:

1/16 --> [1
1/8 --> [2
3/16 --> [3
1/4 --> [4
....
15/16 --> [T
------

Example:

Finds and changes the string:
31'-1 5/8" (W16x31 x 31'-0 5/8")

to the string:
31'-1]0" (W16x31 x 31'-0[0")

Doesn't change the string:
Don't Change / This to anything...

Thanks,
MSR


The function needs to work VERY quickly as it will be run as part of an add
on a batch process.

Any help will be much appreciated.
0 Likes
Message 3 of 4

Anonymous
Not applicable
None really. I thought this would be an easy one for some code junkie. Probably already has it in a tool box somewhere - ?? no? 🙂
0 Likes
Message 4 of 4

Anonymous
Not applicable
Hi Mike
This is not exactly what you looking for
but may helps

~'J'~

Sub test()

Dim strTxt As String, _
fstStr As String, _
endStr As String, _
findStr As String
strTxt = "31'-1 5/8"" (W16x31 x 31'-0 5/8"")"
findStr = "5/8"""
Select Case findStr
Case "5/8"""
fstStr = "[0": endStr = "0]"
Case "1/16"""
fstStr = "[1": endStr = "1]"
Case "1/8"""
fstStr = "[2": endStr = "2]"
Case "3/16"""
fstStr = "[3": endStr = "3]"
Case "1/4"""
fstStr = "[4": endStr = "4]"
'/// etc.
End Select
strTxt = Replace(strTxt, findStr, fstStr)

strTxt = Left$(strTxt, Len(strTxt) - Len(fstStr) - 1) & endStr

MsgBox strTxt

End Sub
0 Likes