[Originally posted by Andrew Murphy]
I need some sort of replace function that will do the following...
If I have a string that has the following (I will use VB code for
If Label1.Caption = "hi" Then Label1.Caption = "Bye"
and I want to make it
If Label12.Caption = "hi" Then Label12.Caption = "Bye"
then I just do a simple replace. BUT my code which I have.....
If InStr(1, Form3.Text1.Text, LastName) <> 0 Then ' Check for occurance of
ÿ ÿ If InStr(1, Form3.Text1.Text, Text1.Text) = 0 Then ' has it already been
ÿ ÿ ÿ ÿ If MsgBox("Do you wish all references to change in your text?",
vbYesNo) = vbYes Then ' Do they want to replace?
ÿ ÿ ÿ ÿ ÿ ÿ Form3.Text1.Text = Replace(Form3.Text1.Text, LastName,
Text1.Text) ' Replace
ÿ ÿ ÿ ÿ End If
ÿ ÿ End If
Doesn't allowed me to make it go back again, ie replace Label12 with Label1.
BECAUSE when I do line 2 it is picking up the LABEL1 in label12.ÿ How can I
make it so that I have an instr couterpart like....
Public Sub AdvInstr(Start, MainText, StringOne, IsNotPartOf)
where it checks to see if StringOne is part of string IsNotPartOf when each
"section" is split up my a vbcrlf a " " (space) or a full stop "."?
need futhur explaination?
[Originally posted by neophile]
Does this do it for you?...
Public Function AdvInstr(Start, Text, Find, Optional Ignore, Optional Compare As VbCompareMethod = vbBinaryCompare) As Long
ÿ Dim lFind As Long
ÿ Dim lIgnore As Long
ÿ lFind = InStr(Start, Text, Find, Compare)
ÿ If Not IsMissing(Ignore) Then
ÿ ÿ ÿ lIgnore = InStr(lFind, Text, Ignore, Compare)
ÿ ÿ ÿ While lFind = lIgnore
ÿ ÿ ÿ ÿ lFind = lFind + 1
ÿ ÿ ÿ ÿ lFind = InStr(lFind, Text, Find, Compare)
ÿ ÿ ÿ ÿ If lFind > 0 Then lIgnore = InStr(lFind, Text, Ignore, Compare)
ÿ ÿ ÿ Wend
ÿ End If
ÿ AdvInstr = lFind
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center