Support Forums
VB.NET Wrap Color BBCode Tags [Reply] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: VB.NET Wrap Color BBCode Tags [Reply] (/showthread.php?tid=25620)



VB.NET Wrap Color BBCode Tags [Reply] - AceInfinity - 03-15-2012

I didn't want to keep it up in PM's so i'm dragging this to the forum where it belongs:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim ColDlg As New ColorDialog
    With ColDlg
        .FullOpen = True
        .ShowDialog()
    End With

    Dim HexColorVal As String = String.Format("{0:X2}{1:X2}{2:X2}", ColDlg.Color.R, ColDlg.Color.G, ColDlg.Color.B)
    TextBox1.SelectedText = AddBBCode(TextBox1.SelectedText, "[color=#" & HexColorVal & "]", "[/color]")
End Sub

Private Function AddBBCode(ByVal StartTag As String, ByVal EndTag As String) As String
    Dim L_ST As Integer = StartTag.Length
    Return TextBox1.SelectedText.Insert(0, StartTag).Insert(TextBox1.SelectedText.Length + L_ST, EndTag)
End Function

There, custom color dialog that wraps selected text in color bbcode tags.


RE: VB.NET Wrap Color BBCode Tags [Reply] - Bill Nye The Science Guy - 03-15-2012

Thanks man, really helped out. Your are the best! I am becoming 10x more active on SF.


RE: VB.NET Wrap Color BBCode Tags [Reply] - AceInfinity - 03-15-2012

I created a quick project out of the code I came up with as well just out of boredom. http://tech.reboot.pro/showthread.php?tid=2105

[Image: 6DZmH.png]


RE: VB.NET Wrap Color BBCode Tags [Reply] - Fragma - 03-15-2012

So you highlight some text, click the button, pick a colour, and it adds the BBCode around the selected text?
Pretty cool. I did something similar a few years back, only it was for a multi-colour text generator for forums and MSN, so the process was a bit different.


RE: VB.NET Wrap Color BBCode Tags [Reply] - AceInfinity - 03-15-2012

Yeah you have the idea of what it does Smile

If you don't input a value specified by some tags, or you don't have anything selected, it will put your ibeam between the tags so you can start typing right after you hit the button too.


RE: VB.NET Wrap Color BBCode Tags [Reply] - BreShiE - 03-15-2012

Ace, you should add in a "preview" button mate, so the app holder can see what their post will be like.


RE: VB.NET Wrap Color BBCode Tags [Reply] - AceInfinity - 03-15-2012

That's an idea, and I was thinking about it too at the time I started this, but left it out after I started working on other things here.

I'll give the user the option to choose their own post template so that it works for other forums as well if I get around to upgrading this program.


RE: VB.NET Wrap Color BBCode Tags [Reply] - Bill Nye The Science Guy - 03-15-2012

Testing
[Image: q3fyv.png]


RE: VB.NET Wrap Color BBCode Tags [Reply] - AceInfinity - 03-15-2012

Looks good Hockey Smile Keep up the good work, I know I took off from the idea trying to help you, but I do know of someone that created something similar to this before me as well.

Can't wait to see the finished product when you're done Smile