Dreamweaver
Well-known member
- Local time
- Today, 16:27
- Joined
- Nov 28, 2005
- Messages
- 2,467
This relates the https://www.access-programmers.co.uk/forums/threads/code-colors-like-in-vb-editor.310948/
It works perfectly When "_" is not found but just can't get it working if there is a "_"
It's must be something I'm doing but blind to it now.
It works perfectly When "_" is not found but just can't get it working if there is a "_"
It's must be something I'm doing but blind to it now.
Code:
Private Sub Cmd_CodeComment_Click()
'=================================================================
'Description: Code Altered From Strive4Peaces Colour Compiler
'Called By: Command Button
'Calling: None
'Parameters: None
'Returns:
'Author: Michael Javes
'Editor(s):
'Date Created: 24th April 2020
'Rev. History:
'Requirements:
'=================================================================
Dim aLine() As String _
, sDeli As String _
, dStrField As String _
, I As Integer _
, dResult As String _
, dComs As String _
, sLine As String _
, dMLine As Boolean _
, dUnder As Integer
On Error GoTo HandleErr
'Setup Items Required
dComs = DDLookUp("DfltComments", "tblPreferences")
'set delimiter for lines
sDeli = vbCrLf
dStrField = Me![Txt_CodeDetails]
dMLine = False
'split code at line breaks
aLine = Split(dStrField, sDeli)
'process each line -- append Comments after First Line
For I = LBound(aLine) To UBound(aLine)
sLine = aLine(I)
'Check Start Of Line For Required Text
If Left(sLine, 16) = "<div>Private Sub" Or Left(sLine, 15) = "<div>Public Sub" _
Or Left(sLine, 21) = "<div>Private Function" Or Left(sLine, 20) = "<div>Public Function" _
Or Left(sLine, 8) = "<div>Sub" Or Left(sLine, 13) = "<div>Function" Then
dUnder = InStr(sLine, "_")
If dUnder > 0 Then 'Found Underscore
'Just Add The Line
dResult = dResult & sLine
Else 'Not Found Underscore add the comments
dResult = dResult & sLine & vbCrLf & dComs & vbCrLf
End If
Else 'Not the start of a sub/function but is dUnder > 0
If dUnder > 0 Then
dResult = dResult & sLine & vbCrLf & dComs & vbCrLf
dUnder = 0 'Reset the Underscore count
Else
dResult = dResult & sLine
End If
End If
Next I
Me![Txt_CodeDetails] = dResult
HandleExit:
Exit Sub
HandleErr:
Select Case Err.Number
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
Resume HandleExit
Resume
End Select
End Sub