Code:
'6b) get code as long string String. This can be very long
Dim TextWithBBCodeEnit As String ' 'Prepares "Pointer" to a "Blue Print" (or Form, Questionnaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quick checks.. But...http://www.mrexcel.com/forum/excel-q...html#post44116
Let TextWithBBCodeEnit = objCliTextCopied.GetText() ''retrieve the text in this instance of the Class. ( Our code as a String with probably BB Code Code tags, vbCr vbLf etc.
Rem 7) Determine length of original text
Dim LenText As Long ' ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
Let LenText = Len(TextWithBBCodeEnit)
MsgBox prompt:="Text with BB Code Character count is " & LenText
Rem 8) Take out BB Code bits from text string.
40 Dim strRmveBBCode As String: Let strRmveBBCode = TextWithBBCodeEnit ' = strBBCode ' This will be adjusted until finally has no BBCode tag pairs
50 Dim Lstr As Long ' This will be adjusted as necerssary for current length ' Long is very simple to handle, - final memory "size" type is known (123.456 and 000.001 have same "size" computer memory ) , and so a Address suggestion can be given for the next line when the variable is filled in. '( Long is a Big whole Number limit (-2,147,483,648 to 2,147,483,647) If you need some sort of validation the value should only be within the range of a Byte/Integer otherwise there's no point using anything but Long.--upon/after 32-bit, Integers (Short) need converted internally anyways, so a Long is actually faster. )
60 Let Lstr = Len(TextWithBBCodeEnit) ' Len(strBBCode)
70 Rem 2) Loop through and get a BB Code section
80 Dim strBBCodePair As String ' for a found valid pair '
' Prepares "Pointer" to a "Blue Print" (or Form, Questionaire not yet filled in, a template etc.)"Pigeon Hole" in Memory, sufficient in construction to house a piece of Paper with code text giving the relevant information for the particular Variable Type. VBA is sent to it when it passes it. In a Routine it may be given a particular "Value", or ("Values" for Objects). There instructions say then how to do that and handle(store) that(those). At Dim the created Paper is like a Blue Print that has some empty spaces not yet filled in. A String is a a bit tricky. The Blue Print code line Paper in the Pigeon Hole will allow to note the string Length and an Initial start memory Location. This Location well have to change frequently as strings of different length are assigned. Instructiions will tell how to do this. Theoretically a specilal value vbNullString is set to aid in quich checks.. But..http://www.mrexcel.com/forum/excel-questions/361246-vbnullstring-2.html#post44116
90 Dim posCurrent As Long 'Current position in the string' Loop Bound variable Count '_-Main Loop==========================
100 For posCurrent = Lstr To 2 Step -1 'Important to go backwards as we chop off behind us so have a less complicated current position. We look at pos-1 in some code parts so we would error if we went back to less than 2
110 '2a) Check for a ]
120 If Mid(strRmveBBCode, posCurrent, 1) = "]" Then
130 Dim posBBCodeTagSrch As Long 'For search through possible valid BBCode Section'_-Loop for Pos tag pair section--
140 Dim BcrdEEnd As Long: Let BcrdEEnd = posCurrent 'Position of possible End Code Tag End
150 For posBBCodeTagSrch = posCurrent - 1 To 2 Step -1 'PosCurrent is set here at loop start. ###It is not effected by cardinally sining changing PosCurrent Loop Bound variable caount in Outer main Loop
160 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then GoTo NxtCESPosPos ' If we hit another ] then start again to see if is a valid BB code section
170 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "/" And Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "[" Then 'We hit start of a BB Code end tag
180 Dim BcrdESt As Long: Let BcrdESt = posBBCodeTagSrch - 1 'Position of End Code Tag Start
190 Exit For ' We leave this For the End Code Tag Start Search, Exit For with a [ at posBBCodeTagSrch-1
200 Else 'Not found start of end Tag or stop of end Tag.
210 End If
220 NxtCESPosPos: Next posBBCodeTagSrch ' go back in possible BB code string
230 If posBBCodeTagSrch = 3 Then Exit Sub 'case we never found the start of an End Code Tag
240 For posBBCodeTagSrch = posBBCodeTagSrch - 2 To 2 Step -1 ' Once again ### the start is set and fixed, the Loop Bound Variable Count will change
250 If Mid(strRmveBBCode, posBBCodeTagSrch, 1) = "]" Then
260 If Mid(strRmveBBCode, posBBCodeTagSrch - 1, 1) = "]" Then GoTo NxtCSSPosPos ' If we hit another ] then start again to see if is a valid BB code start section
270 Dim BcrdSEnd As Long: Let BcrdSEnd = posBBCodeTagSrch 'Position of possible Start Code Tag End
280 Dim LTagStLoop As Long 'Last loop to find start of start Code Tag
290 For LTagStLoop = posBBCodeTagSrch - 1 To 1 Step -1 '_- Second inner loop___________________________
300 If Mid(strRmveBBCode, LTagStLoop, 1) = "[" Then
310 Dim BcrdSSt As Long 'Have to put it here, - I may occaisionally have to set it to 0 in next line
320 If Mid(strRmveBBCode, LTagStLoop + 1, 1) = "/" Then Let BcrdEEnd = BcrdSEnd: Let BcrdSEnd = 0: Let BcrdESt = LTagStLoop: Let BcrdSSt = 0: Let posBBCodeTagSrch = LTagStLoop: GoTo NxtCSSPosPos ' Found a second end Code Tag. So change the previous found start and stop , and adjust the Loop Bound variable Count appropriately for a new search for a start Code Tag
330 Let BcrdSSt = LTagStLoop
340 Let posCurrent = BcrdSSt 'End of Code Tag section search
350 GoTo FkOffCrd ' We leave this For the start Code Tag Start Search and go to Fuk Off Crd:
360 Else ' Still looking for start of start Code Tag
370 End If
380 Next LTagStLoop '_- Second inner loop________________________________________________________________
390 If LTagStLoop = 1 Then GoTo TheEnd 'Case we found a start start [ at 1 or failed to find a start start [ for the complete possible Code Tag section search
400 Else 'Not found end of start Tag or start of start Tag
410 End If
420 NxtCSSPosPos: Next posBBCodeTagSrch ' go back in possible BB code string'_-Loop for Pos tag pair section-----------------
Bookmarks