Colour text in code tags? (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 16:02
Joined
Sep 21, 2011
Messages
14,044
Hi Jon,

Is there anyway to 'show' coloured text within code tags.?

When editing it, it shows Bold, colour etc, but when displayed, nothng.?

Trying to highlight a piece of code easily for a member who is asking for help, otherwise it has to be outside the code tags.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:02
Joined
Oct 29, 2018
Messages
21,358
Sure. Use rich. For example.
Rich (BB code):
bold and red
 

isladogs

MVP / VIP
Local time
Today, 16:02
Joined
Jan 14, 2017
Messages
18,186
Or use the SQL language option in the code tags. For example:
SQL:
'###############################################
#If VBA7 Then 'A2010 or later (32/64-bit)
    Declare PtrSafe Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)     
#Else 'A2007 or earlier
    Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
#End If
'###############################################

Sub Wait(N As Integer)
'creates a delay while other code executes
'N = number of seconds to wait

    Dim i As Integer
    For i = 1 To N
        Sleep 1000              'sleep function from api library file
    Next
    DoEvents
End Sub

Or use Crystal's approach to colour comments green https://www.access-programmers.co.uk/forums/threads/color-comments-green.310752/#post-1685050
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:02
Joined
Sep 21, 2011
Messages
14,044
Ah OK, thanks both.

I was aware of Crystal's comments DB, but just wanted to highlight portions within a line of code.
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:02
Joined
Sep 21, 2011
Messages
14,044
Colin,

Just tried SQL and I got this?

SQL:
 strSQL = "UPDATE tblInventory SET [AmtInStock] = [AmtInStock] [B]+[/B] " & CStr( Me.[Amount] ) & " ;"

I was trying to highlight the + sign in the code in another thread.

I'll experiment with the other types here
Rich (BB code):
 strSQL = "UPDATE tblInventory SET [AmtInStock] = [AmtInStock] + " & CStr( Me.[Amount] ) & " ;"

Cheers theDBGuy, seems Rich Text will do what I was attempting to show.
 

strive4peace

AWF VIP
Local time
Today, 11:02
Joined
Apr 3, 2020
Messages
1,003
hi Gasman ,

Rich BBcode:

bbrcodes.png


Rich (BB code):
[highlight=yellow]the highlight tag doesn't seem to work in rich text code on this forum (yet?)[/highlight]
[BGCOLOR=#FFA]BGCOLOR doesn't work either[/bgcolor]
but you can use bold, underline, and italic
and different colors for the text such as green, red, blue
and combine effects like bold+purple
 
Last edited:

strive4peace

AWF VIP
Local time
Today, 11:02
Joined
Apr 3, 2020
Messages
1,003
ps

you also have to toggle the BB code indicator to show and edit codes OR hide the codes and show effects
ToggleBBcode.png
 
Last edited:

Minty

AWF VIP
Local time
Today, 16:02
Joined
Jul 26, 2013
Messages
10,354
Although not directly related, I'd much prefer to have the Code option available outside of the drop-down in the editor, I think it's why new members don't use it as it's not obvious.
And a option for vba in the available languages would be brilliant. (Default obvs) :sneaky:

Code:
 

isladogs

MVP / VIP
Local time
Today, 16:02
Joined
Jan 14, 2017
Messages
18,186
Although not directly related, I'd much prefer to have the Code option available outside of the drop-down in the editor, I think it's why new members don't use it as it's not obvious.
And a option for vba in the available languages would be brilliant. (Default obvs) :sneaky:

Code:

Agree with both comments. The code window is more powerful than before but its too hidden away.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 16:02
Joined
Feb 19, 2013
Messages
16,553
@Jon on this subject I have two issues with the code tag

the first is if I type the code in the thread and then decide to surround with code tags (as it used to be) then a) I have to remember to copy it first to paste into the code window and b) when pasted it becomes double spaced. Guess I'll have to change my ways

The second is toggle BB codes - this disables the ribbon - but perhaps I'm missing something?
 

strive4peace

AWF VIP
Local time
Today, 11:02
Joined
Apr 3, 2020
Messages
1,003
@Jon on this subject I have two issues with the code tag

the first is if I type the code in the thread and then decide to surround with code tags (as it used to be) then a) I have to remember to copy it first to paste into the code window and b) when pasted it becomes double spaced. Guess I'll have to change my ways

The second is toggle BB codes - this disables the ribbon - but perhaps I'm missing something?

hi CJ ,
I've noticed this too! ... but anymore, I use my add-in to color comments, even if there aren't any, since I usually have some database in Access open and its quick. It puts tags around the code and doesn't double-space the lines. Download it here:

Color Comments Green
https://www.access-programmers.co.uk/forums/threads/color-comments-green.310752/
 

Jon

Access World Site Owner
Staff member
Local time
Today, 16:02
Joined
Sep 28, 1999
Messages
7,304
@Jon on this subject I have two issues with the code tag

the first is if I type the code in the thread and then decide to surround with code tags (as it used to be) then a) I have to remember to copy it first to paste into the code window and b) when pasted it becomes double spaced. Guess I'll have to change my ways

The second is toggle BB codes - this disables the ribbon - but perhaps I'm missing something?
It sounds like there is some kind of text formatting issue. So, perhaps you could strip the formatting of that text once copied to the clipboard. Not sure if this works: https://www.addictivetips.com/windo...from-clipboard-text-with-a-keyboard-shortcut/

Or, have you tried the Inline code thing instead?

To be frank, I have no idea what the BB toggle thing does!
 

strive4peace

AWF VIP
Local time
Today, 11:02
Joined
Apr 3, 2020
Messages
1,003
not all work -- first tested div for background color since other tags I tried for changing background for text didn't work either ... but thanks, Jon ... more to explore ;)
 

strive4peace

AWF VIP
Local time
Today, 11:02
Joined
Apr 3, 2020
Messages
1,003
Jon, is there a list somewhere of the rich BBcode tags that AWF supports in the Code=rich tag?
 

Jon

Access World Site Owner
Staff member
Local time
Today, 16:02
Joined
Sep 28, 1999
Messages
7,304
I have no idea. You can always try Googling xenforo bbcode tags list.
 

Minty

AWF VIP
Local time
Today, 16:02
Joined
Jul 26, 2013
Messages
10,354
I meant to add that MrExcel has a VBA option in its code tag languages and is run on XenForo2 so it must be possible.
 

Users who are viewing this thread

Top Bottom