Code part 4 of 4 parts
Code:
430 FkOffCrd: Rem 3) "I think we come here with a complete set of 4 positions"
440 If BcrdEEnd <> 0 And BcrdESt <> 0 And BcrdSEnd <> 0 And BcrdSSt <> 0 Then 'Just to check'
450 Dim SttBcrd As String, StpBcrd As String ' Start and stop tags
460 Let SttBcrd = Mid(strRmveBBCode, BcrdSSt, BcrdSEnd - BcrdSSt + 1): Let StpBcrd = Mid(strRmveBBCode, BcrdESt, BcrdEEnd - BcrdESt + 1)
470 Dim SttWrd As String, StpWrd As String ' like |Color=Red|, |/Color|
480 Let StpWrd = Mid(StpBcrd, 3, Len(StpBcrd) - 3) ' like Color from |/Color| - Whole Word, from 3rd Chr , for Length as WholeWord-3
490 Let SttWrd = Mid(SttBcrd, 2, Len(StpWrd)) ' like Color from |Color=Red|
500 If UCase(SttWrd) = UCase(StpWrd) And Mid(StpBcrd, 2, 1) = "/" Then 'Ucase allows for differences in cases And Mid(SttBcrd, Len(SttWrd) + 2, 1) = "=" Then
510 Let strRmveBBCode = Replace(strRmveBBCode, SttBcrd, "", 1, 1) ' Replace in ( strRmveBBCode , the start tag , with no string , start loooking from and return from character 1 )
515 Let strRmveBBCode = Replace(strRmveBBCode, StpBcrd, "", 1, 1)
520 Else 'No shortening of string foe invalid tag word
530 End If
540 Else ' no last ] of a possible Code section yet, so keep going back down in the main string
550 End If
560 Else
570 End If
580 Next posCurrent '_-===Main Loop========================================================================================
'590 TheEnd:
600 MsgBox prompt:="" & strRmveBBCode & "": Debug.Print "" & strRmveBBCode & "" 'Hit Ctrl+g when in VB Editor Window, reveal Immediate window after code run
Dim RapedText As String: Let RapedText = strRmveBBCode ' TextWithBBCodeEnit with BB Code Code tags removed
Rem 9) This a Another Object from class to be sure we have the data in the Clipboard
'Dim objDat As DataObject
'Set objDat = New DataObject 'Set to a new Instance ( Blue Print ) of dataobject
Dim objDat As Object
Set objDat = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
'9b) Put in (and Get back from clipboard) the raped text.
objDat.SetText Text:=RapedText 'Make Data object's text equal to original text without the BB Code Code Tags
objDat.PutInClipboard 'Place current Data object into the Clipboard
objDat.GetFromClipboard 'All that is in the Clipboard goes in this Data Object second instance of the Class.
Dim TxtOut As String: Let TxtOut = objDat.GetText() 'retrieve the text in this second instance of the Class. ( In this case all in it is the text and possibly vbCr and vbLf )
MsgBox prompt:="You dumped in Clipboard this " & vbCr & RapedText & vbCr & "and if you try to get it, you should get" & vbCr & TxtOut & ""
Rem 10a) Code Part 3) Belt and braces check. A check is then done finally to see if the two raped from tags strings are the same
If NewWordText <> RapedText Then MsgBox prompt:="Text from Word Dialogue Box Find Replace Wild card way, and " & vbCrLf & "Long String manipulation way are not the same. Oh dear"
'10b) Tidy up.
TheEnd: ' ( Come here always, even on a unpredictable error ) or i wouod If i had an error Handler, Lol.
Set objDat = Nothing ' Good practice... maybe....
Set objCliTextCopied = Nothing ' ....... http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring.html#post4414065
End Sub
Bookmarks