![]() |
|
[VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework) +--- Thread: [VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 (/Thread-VB-Net-CodeSyntax-BBcode-Syntax-Highlighter-v1-0) |
[VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 - Coder-san - 05-31-2011 CodeSyntax - BBcode Syntax Highlighter v1.0
![]() Info: CodeSyntax is a BBcode highlighter for languages like VB.Net and C#. Since we do not have codeblock for programming languages and [php] codeblock looks confusing to recreate, I made this for syntax highlighting. You can probably fool the program in one way or the other if you look carefully, so don't get too over-excited and shout "BUGGY" on top of your lungs. Just post here and I'll try to fix them. ![]() Input: Code: If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then
ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
Else
If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then
ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
'Else
' ArrWords(intW) = ArrWords(intW)
End If
End IfOutput: If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then ArrWords(intW) = "[color=# 32CD32]" & ArrWords(intW) & "[/ color]" Else If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then ArrWords(intW) = "[color=# 87CEEB]" & ArrWords(intW) & "[/ color]" 'Else ' ArrWords(intW) = ArrWords(intW) End If End If [link=http://hotfile.com/dl/119439886/9a59567/CodeSyntax.exe.html]
![]() CodeSyntax - BBcode Syntax Highlighter v1.0 (69 Kb) [/link] Spoiler: SourceCode: Private Sub btnMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVBnet.Click, btnCsharp.Click
Dim ArrLines As String() = richText.Lines
Dim tempBuilder As New System.Text.StringBuilder
For intL As Integer = 0 To ArrLines.Length - 1
Dim ArrWords As String() = ArrLines(intL).Split(" ")
If ArrWords.Length > 1 Then
For intW As Integer = 0 To ArrWords.Length - 1
If ArrWords(intW).Length > 0 Then
If CType(sender, Button).Text = "C#" Then
If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then
ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
Else
If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then
ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
End If
End If
Else
If ArrLines(intL).Contains("'") AndAlso ArrLines(intL).Contains("""'""") = False Then
ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
Else
If My.Resources.vbSyntax.Contains(ArrWords(intW)) Then
ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
End If
End If
End If
End If
tempBuilder.Append(ArrWords(intW) & " ")
Next
End If
tempBuilder.Append(vbCrLf)
Next
richText.Text = tempBuilder.ToString
End SubNote: Tabs and spaces in code are not preserved since no current MyBB codeblock provides blank space preservation other than [code] ( it ignores every BBcode so it doesn't matter). This is a huge problem and a big code output from CodeSyntax looks confusing without blank spaces. Unfortunately nothing can be done for it currently. RE: [VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 - 1234hotmaster - 05-31-2011 wow great program and very nice usage! since there is no [VB] tag
|