Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB.NET Wrap Color BBCode Tags [Reply]
#1
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.
Reply
#2
Thanks man, really helped out. Your are the best! I am becoming 10x more active on SF.
Reply
#3
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]
Reply
#4
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.
Reply
#5
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.
Reply
#6
Ace, you should add in a "preview" button mate, so the app holder can see what their post will be like.
Reply
#7
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.
Reply
#8
Testing
[Image: q3fyv.png]
Reply
#9
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

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.Net][SRC]ProgressBar Color HF~Legend 14 6,816 09-08-2012, 04:18 PM
Last Post: spesificrelax
  [Q] How to change the ToolStripSeparator background color?? Robi888 3 1,344 11-16-2011, 06:28 AM
Last Post: TalishHF
  My Menu + Background Color project [SRC] ★ASI_F★™ 4 1,225 07-12-2011, 07:26 PM
Last Post: Relapse
  Multi-Color Text Gen - [SOURCE] Fragma 5 1,023 02-22-2011, 02:57 PM
Last Post: ThePrinCe
  Html Color Helper the_legend_nl 6 1,556 11-10-2010, 12:14 AM
Last Post: the_legend_nl

Forum Jump:


Users browsing this thread: 1 Guest(s)