Hi,
If you look at the line:
ReplaceString oEnt, "S", "N"
You can change that line to be:
ReplaceString oEnt, "N", "S"
or
ReplaceString oEnt, "E", "W"
In each case the first string is replaced by the second one
So now all you need is a means of distinguishing which repalcement you wish
to make which can be done like this:
If TypeOf oEnt Is AcadText Then
Set oText = oEnt
sTmp = oText.TextString
WhichReplacement oEnt, sTmp
ElseIf TypeOf oEnt Is AcadMText Then
Set oMText = oEnt
sTmp = oMText.TextString
WhichReplacement oEnt, sTmp
Else
MsgBox "The selected object was neither Text or MText", vbInformation
End If
Function WhichReplacement (oEnt as AcadEntity, sTmp as String)
If Instr(sTmp, "N" > 0 Then
ReplaceString oEnt, "N", "S"
ElseIf Instr(sTmp, "S" > 0 Then
ReplaceString oEnt, "S", "N"
ElseIf Instr(sTmp, "W" > 0 Then
ReplaceString oEnt, "W", "E"
ElseIf Instr(sTmp, "E" > 0 Then
ReplaceString oEnt, "E", "W"
End If
End Function
I'm unsure if you expect combinations of N and W or N and E etc. If you do
then the code statements need to be changed to:
Function WhichReplacement (oEnt as AcadEntity, sTmp as String)
If Instr(sTmp, "N" > 0 Then
ReplaceString oEnt, "N", "S"
ElseIf Instr(sTmp, "S" > 0 Then
ReplaceString oEnt, "S", "N"
End If
If Instr(sTmp, "W" > 0 Then
ReplaceString oEnt, "W", "E"
ElseIf Instr(sTmp, "E" > 0 Then
ReplaceString oEnt, "E", "W"
End If
End Function
--
Also, you may care to remove the messagebox from the ReplaceString Function,
as with these changes, you don't need it there
I haven't tested this, and may have missed a couple of Dim statements, but
you can add those as needed
Regards
Laurie Comerford
wrote in message
news:5864868@discussion.autodesk.com...
Thanks Laurie. Can you do the same thing but like this?
Change all "N" to "S"
all "S" to "N"
all "E" to "W"
and all "W" to "E"
?
I thought I could figure it out with a little help of example usage but it
is harder than I thought.