specific color codes for different types of code (1 Viewer)

vba_php

Forum Troll
Local time
Today, 12:47
Joined
Oct 6, 2019
Messages
2,884
hey Jon,

Is it possible that we can do something like this for people who post code that they need help with? For instance, a lot of other forums do this same sort of thing. The image below shows what www.mrexcel.com is doing. Can you adopt the forum software here to do the same thing? Since VBA is the primary language we deal with here, can you do the same thing as MrExcel is doing? They use the following specifications to achieve what is shown in the image:
Code:
[ code = vba ]code here[ / code ]
 

Attachments

isladogs

CID Moderator
Staff member
Local time
Today, 18:47
Joined
Jan 14, 2017
Messages
13,437
Adam
Considering your choice of user name and supposed proficiency in php, are you totally incapable of seeing what's already available?

PHP:
Private Sub txtDateChecked_AfterUpdate()
    
    If Me.txtDateChecked <> "" Then
        CurrentDb.Execute "UPDATE tblModules SET tblModules.DateChecked = #" & Format(Me.txtDateChecked, "mm/dd/yyyy") & "#" & _
            " WHERE tblModules.ModuleName='" & strModule & "';"
    Else
        CurrentDb.Execute "UPDATE tblModules SET tblModules.DateChecked = Null" & _
            " WHERE tblModules.ModuleName='" & strModule & "';"
    End If
End Sub
 

vba_php

Forum Troll
Local time
Today, 12:47
Joined
Oct 6, 2019
Messages
2,884
Adam
Considering your choice of user name and supposed proficiency in php, are you totally incapable of seeing what's already available?
there you go again with your obsession of accusing me of being a fake talent. You and Tony both. Perhaps someday I will vacation in London or England in general and call you up so you can see for yourself, in real life? You probably wouldn't agree to that though....

I perhaps missed the PHP tag availability, but what about the VBA image I posted? that's not currently available here, is it? I tested what mrExcel uses, and it did not work in my test post. Can't Jon implement that?
 

isladogs

CID Moderator
Staff member
Local time
Today, 18:47
Joined
Jan 14, 2017
Messages
13,437
Thanks for the invite but I'm going to be very busy that day.
 

isladogs

CID Moderator
Staff member
Local time
Today, 18:47
Joined
Jan 14, 2017
Messages
13,437
No. I'll be seeing a real friend.
 

Minty

AWF VIP
Local time
Today, 18:47
Joined
Jul 26, 2013
Messages
7,108
I was thinking more like the sound of one hand clapping
 

vba_php

Forum Troll
Local time
Today, 12:47
Joined
Oct 6, 2019
Messages
2,884
I was thinking more like the sound of one hand clapping
you're gonna have to expand on that one my friend. I don't get it. why would I applaud myself or Colin if I was heading to meet him? He thinks I have no technical skill, and I've shown myself to be a jerk in my posts many times. Thus, your post makes no sense to me. :confused:
 

Minty

AWF VIP
Local time
Today, 18:47
Joined
Jul 26, 2013
Messages
7,108
Sigh...

Perhaps if you were travelling to our damp and dreary corner of the world you might be relatively quiet on here.

I suspect this would also lead to a mass exodus to another sunnier clime by the UK contingent.
 

vba_php

Forum Troll
Local time
Today, 12:47
Joined
Oct 6, 2019
Messages
2,884
I suspect this would also lead to a mass exodus to another sunnier clime by the UK contingent.
is this a reference to Moses' huge effort to get the people out of Egypt and away from the corruption of the pharaoh? If it is, it's kind of a *reverse* reference.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:47
Joined
May 21, 2018
Messages
3,197
Maybe I am not following this correctly or know how to do this, but what is wrong with Adam's question? I wrapped the following sub in PHP and get colors, but those colors are meaningless to me. They are basically random and give no context. Could we not get some functionality that could properly color vba. In Visual Studio the coloring is really helpful

PHP:
Private Sub cmd_Report_Click()
'On Error GoTo Err_Handler      'Remove the single quote from start of this line once you have it working.
    'Purpose:       Filter a report to a date range.
    'Documentation: http://allenbrowne.com/casu-08.html
    'Note:          Filter uses "less than the next day" in case the field has a time component.
    Dim strReport As String
    Dim strDateField As String
    Dim strWhere As String
    Dim lngView As Long
    Const strcJetDate = "\#mm\/dd\/yyyy\#"  'Do NOT change it to match your local settings.
    
    'DO set the values in the next 3 lines.
    strReport = "rpt_Inspections"      'Put your report name in these quotes.
    strDateField = "[DateOfInspection]" 'Put your field name in the square brackets in these quotes.
    lngView = acViewPreview     'Use acViewNormal to print instead of preview.
    
    'Build the filter string.
    If IsDate(Me.txt_DateFrom) Then
        strWhere = "(" & strDateField & " >= " & Format(Me.txt_DateFrom, strcJetDate) & ")"
    End If
    If IsDate(Me.txt_DateTo) Then
        If strWhere <> vbNullString Then
            strWhere = strWhere & " AND "
        End If
        strWhere = strWhere & "(" & strDateField & " < " & Format(Me.txt_DateTo + 1, strcJetDate) & ")"
    End If
        
  If Trim(Me.cbo_Worker & "") <> "" Then
        If strWhere <> vbNullString Then
            strWhere = strWhere & " AND "
        End If
        strWhere = strWhere & "[Worker] = '" & Me.cbo_Worker & "'"
   Else
        MsgBox "Please, choose worker!"
        Exit Sub
    End If
    
    ' check if the strWhere has some value
    If Trim(strWhere) = "" Then strWhere = "(1=1)"
        
    'Close the report if already open: otherwise it won't filter properly.
    If CurrentProject.AllReports(strReport).IsLoaded Then
        DoCmd.Close acReport, strReport
    End If
    
    'Open the report.
    'Debug.Print strWhere        'Remove the single quote from the start of this line for debugging purposes.
    DoCmd.OpenReport strReport, lngView, , strWhere

Exit_Handler:
    Exit Sub

Err_Handler:
    If Err.Number <> 2501 Then
        MsgBox "Error " & Err.Number & ": " & Err.Description, vbExclamation, "Cannot open report"
    End If
    Resume Exit_Handler
End Sub

Even better could be get a sql formatter. I often clean up people's unreadable SQL using a free SQL formatter. It would be really helpful, if it was possible.

 

Attachments

vba_php

Forum Troll
Local time
Today, 12:47
Joined
Oct 6, 2019
Messages
2,884
I wrapped the following sub in PHP and get colors, but those colors are meaningless to me. They are basically random and give no context.
Maj,

Those PHP codes make perfect sense if you are a PHP developer and use a PHP IDE like Eclipse or Dreamweaver.
Could we not get some functionality that could properly color vba. In Visual Studio the coloring is really helpful
I think over at MrExcel, the color coding they use is actually what is found in Visual Studio (but of course, not related to VBA itself). But I haven't checked on that officially, as I'm only doing 1 VS project right now. Does that look right to you?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:47
Joined
May 21, 2018
Messages
3,197
I think over at MrExcel, the color coding these use is actually what is found in Visual Studio. But I haven't check on that officially. Does that look right to you?
The coloring in VS are configurable, but regardless if same or not that coloring has meaning to a VB developer. VB code is one color, literal strings another, variables another. The PHP color does little for me. Pretty much every part of the code is red.

If interested this is the SQL formatter I use, but there are others.
http://www.dpriver.com/pp/sqlformat.htm
 

The_Doc_Man

Happy Retired Curmudgeon
Local time
Today, 12:47
Joined
Feb 28, 2001
Messages
17,083
Those colors make perfect sense, except they don't because they are inconsistent. In post #14, the coloring is totally inconsistent for these lines:

PHP:
    'Purpose:       Filter a report to a date range.
    'Documentation: http://allenbrowne.com/casu-08.html
    'Note:          Filter uses "less than the next day" in case the field has a time component.
One is blue after the apostrophe but the other two are red.

These lines have colors all over the map.

PHP:
    'Close the report if already open: otherwise it won't filter properly.
    If CurrentProject.AllReports(strReport).IsLoaded Then
        DoCmd.Close acReport, strReport
    End If
    
    'Open the report.
    'Debug.Print strWhere        'Remove the single quote from the start of this line for debugging purposes.
    DoCmd.OpenReport strReport, lngView, , strWhere
Perfect sense? I'm not perfect, but often I can tell on the sense-o-meter whether relative to me, I'm looking up or looking down. That color scheme ain't looking up.
 

Tera

Registered User.
Local time
Tomorrow, 02:47
Joined
Feb 2, 2019
Messages
1,076
Those colors make perfect sense,
except they don't because they are inconsistent. In post #14, the coloring is totally inconsistent for these lines:

PHP:
    'Purpose:       Filter a report to a date range.
    'Documentation: http://allenbrowne.com/casu-08.html
    'Note:          Filter uses "less than the next day" in case the field has a time component.
PHP:
    'Close the report if already open: otherwise it won't filter properly.
    If CurrentProject.AllReports(strReport).IsLoaded Then
        DoCmd.Close acReport, strReport
    End If
    
    'Open the report.
    'Debug.Print strWhere        'Remove the single quote from the start of this line for debugging purposes.
    DoCmd.OpenReport strReport, lngView, , strWhere
One is blue after the apostrophe but the other two are red.
PHP tag starts red font when it finds a ' and ends it when it finds the second '.
If it doesn't find the second ' , the font would be red up to the end.

Keywords are in green. Normal code is in blue.
 
Last edited:

The_Doc_Man

Happy Retired Curmudgeon
Local time
Today, 12:47
Joined
Feb 28, 2001
Messages
17,083
Tera, that doesn't explain the debug.print coloration very well. But since I am retired and have neither the need nor the interest, I won't worry too much about it.
 

Micron

AWF VIP
Local time
Today, 13:47
Joined
Oct 20, 2018
Messages
3,212
Sure it looks nice and is probably thought to be very useful by most of us when writing a lot of code for a project, but for I don't see the need for the amount posted in this forum. Besides, half the time it seems like posted code posted isn't within tags anyway, which would make the feature useless in those cases. This is just a guess, but I'd say this forum software is a generation behind AccessForums.net, which is a generation behind Mr.Excel (which by the way, is a recent upgrade). I lament some of the oddities here but I think I'm pragmatic enough about that to realize that upgrading would cost money - money that would produce little or no return on investment.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom