Forum Moderators: coopster

Message Too Old, No Replies

Replacing strings (any case) for array and colour?

How to use regex to replace strings in array and colour output

         

Simon_Lloyd

12:34 pm on Feb 21, 2009 (gmt 0)

10+ Year Member



Hi all, firstly i have little or no php or html coding experience, but learning fast, i run a forum using vbulletin, my site deals with Q & A's on Microsoft office apps and VBA (Microsofts version of VB), currently a user can add some vba to their post, highlight it and click the CODE tags, all well and good, however i would like to enhance their experience by making the code inside the bbcode tags look like it has created in the VBE (you may know it as the IDE).

I would like to find all occurrences of stings (any case) found in the list below and replace them with the Exact match from the list below and colour it BLUE, any text found after a ' within the bbcode tag should appear green.

I would also like to indent the code like this:

For i = 1 To UBound(a, 1) 
If Not IsEmpty(a(i, 1)) Then
x = Application.Match(a(i, 1), b, 0)
If IsError(x) Then
j = j + 1: w(j, 1) = a(i, 1)
End If
End If
Next
If j > 0 Then Range("m5").Resize(j).Value = w

SORRY Indenting won't show in this forum!

[edited by: Simon_Lloyd at 12:40 pm (utc) on Feb. 21, 2009]

Simon_Lloyd

12:36 pm on Feb 21, 2009 (gmt 0)

10+ Year Member



Sorry i forgot the list!
'Application',
'AddressOf',
'Alias',
'And',
'Any',
'As',
'Binary',
'Boolean',
'ByRef',
'Byte',
'ByVal',
'Call',
'Case',
'CBool',
'CByte',
'CCur',
'CDate',
'CDbl',
'CInt',
'CLng',
'Close',
'Const',
'CSng',
'CStr',
'Currency',
'CVar',
'CVErr',
'Date',
'Debug',
'Declare',
'DefBool',
'DefByte',
'DefCur',
'DefDate',
'DefDbl',
'DefInt',
'DefLng',
'DefObj',
'DefSng',
'DefStr',
'DefVar',
'Dim',
'Do',
'Double',
'Each',
'Else',
'End',
'Enum',
'Eqv',
'Erase',
'Error',
'Event',
'Exit',
'For',
'Friend',
'Function',
'Get',
'Global',
'GoSub',
'GoTo',
'If',
'Imp',
'Implements',
'In',
'Input',
'Integer',
'Is',
'LBound',
'Len',
'Let',
'Lib',
'Like',
'Line',
'Lock',
'Long',
'Loop',
'LSet',
'Mod',
'Msgbox',
'Name',
'New',
'Next',
'Not',
'Nothing',
'Null',
'Object',
'On',
'Open',
'Option Base 1',
'Option Compare Binary',
'Option Compare Database',
'Option Compare Text',
'Option Explicit',
'Option Private Module',
'Optional',
'Or',
'Output',
'ParamArray',
'Preserve',
'Print',
'Private',
'Property',
'Public',
'Put',
'RaiseEvent',
'Random',
'Read',
'ReDim',
'Resume',
'Return',
'RSet',
'Seek',
'Select',
'Set',
'Single',
'Spc',
'Static',
'Step',
'Stop',
'String',
'Sub',
'Tab',
'Then',
'To',
'Type',
'UBound',
'Unlock',
'Variant',
'Wend',
'While',
'With',
'WithEvents',
'Write',
'Xor',
LIST CHANGED DUE TO SIZE ON SCREEN

[edited by: Simon_Lloyd at 12:41 pm (utc) on Feb. 21, 2009]

Simon_Lloyd

11:38 am on Feb 24, 2009 (gmt 0)

10+ Year Member



Any ideas with this?

Regards,
Simon