|
-
Feb 6th, 2011, 10:08 AM
#1
Thread Starter
Junior Member
Helo with a simple 'color code' thingy in vb6.
Ok so. I tried to do this with a rich text box.
You enter ^1Test^2Test^3Test and it converts it to TestTestTest.
But I'm really having trouble removing the '^1' and '^2' stuff without losing the colors.
I tried replace and I was wondering if there is any other way I could do it.
Anyway thanks 
EDIT: Help*. Stupid keyboard
Last edited by SpioR; Feb 6th, 2011 at 10:09 AM.
Reason: I *****ed up the title :/
-
Feb 6th, 2011, 11:19 AM
#2
Re: Helo with a simple 'color code' thingy in vb6.
So, you don't want to display the markers that you used to color the text ?
I think, it is better to use a DHTMLedit control or a WebBroser control instead of RichTextBox control, so that you could use the HTML styling to your text.
An example using DHTMLedit control (Project menu --> Components --> DHTML Edit Control for IE5):
vb Code:
Private Sub Form_Load()
DHTMLEdit1.DocumentHTML = "<html><body><font color=""red"">Test</font><font color=""green"">Test</font><font color=""yellow"">Test</font></body></html>"
End Sub
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 6th, 2011, 12:09 PM
#3
Thread Starter
Junior Member
Re: Helo with a simple 'color code' thingy in vb6.
I didn't mean just these TestTestTest stuff.
I ment like I write something with the ^1, ^2 stuff and it gets colored 
If it was just testtest that would be easy
-
Feb 6th, 2011, 09:24 PM
#4
Re: Helo with a simple 'color code' thingy in vb6.
You want to know how to color it or to hide it ?
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 7th, 2011, 11:58 AM
#5
Thread Starter
Junior Member
Re: Helo with a simple 'color code' thingy in vb6.
<.<
Color the text and remove the ^1, ^2 stuff.
Sounds simple, but it's not D:
-
Feb 7th, 2011, 10:02 PM
#6
Re: Helo with a simple 'color code' thingy in vb6.
So, you're using ^1, ^2, etc. as your own personal markup symbols? That is, the user types ^1Text^2Is^3Here and somehow triggers your routine which converts everything following the ^1 until the ^2 to be the first color, etc. Is this correct? I tend to agree that switching to HTML could be simpler. The underlying RTF syntax is like LaTeX, but evil instead of good.
If you want to use RTF, post your current code. If you have color coding working, it's strange that you can't just Replace$(MyRTF.TextRTF, "^1", "") and get rid of the markup.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Feb 8th, 2011, 12:37 AM
#7
Re: Helo with a simple 'color code' thingy in vb6.
I did a quick example:
vb Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Long
Dim j As Long
Dim k As Long
i = 1
k = 0
Do While i < Len(RichTextBox1.Text) And k <> Len(RichTextBox1.Text)
j = InStr(i, RichTextBox1.Text, "^", vbTextCompare) '~~~ Starting marker's position
k = InStr(j + 1, RichTextBox1.Text, "^", vbTextCompare) - 1 '~~~ End marker's position
If k = -1 Then k = Len(RichTextBox1.Text) '~~~ If an end marker is not found, the text upto the end will be selected
'~~~ Selecting the text
RichTextBox1.SelStart = j
RichTextBox1.SelLength = k - j
RichTextBox1.SelColor = vbRed '~~~ Coloring it. As this is an illustration on how to color the text, you have to do the coding for selecting the color based on the marker value (^1=red, ^2=green, etc..) yourself
RichTextBox1.SetFocus '~~~ To see the selection
i = k
Loop
End Sub
See if it could get you started.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 8th, 2011, 03:45 AM
#8
Thread Starter
Junior Member
Re: Helo with a simple 'color code' thingy in vb6.
Hmm. Yeah works...somehow...but it didn't remove the ^1 :/
And @ jemidiah um...what's the difference between Replace and Replace$ o_o
I always use replace lul.
-
Feb 8th, 2011, 06:12 AM
#9
Re: Helo with a simple 'color code' thingy in vb6.
 Originally Posted by SpioR
Hmm. Yeah works...somehow...but it didn't remove the ^1 :/
And @ jemidiah um...what's the difference between Replace and Replace$ o_o
I always use replace lul.
Yeah.. It has to be modified to meet your needs. That code was just an example to get you started.
I think, Replace() will return a Variant whereas Replace$() will return a String.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Feb 8th, 2011, 11:53 AM
#10
Thread Starter
Junior Member
Re: Helo with a simple 'color code' thingy in vb6.
-
Feb 9th, 2011, 02:28 AM
#11
Re: Helo with a simple 'color code' thingy in vb6.
There is an alternative method into this: instead of using SelColor etc. you can instead manipulate TextRTF & SelTextRTF. RTF is a syntax of it's own for marking up text color. However, going this route is on the more advanced side because you have to make sure your output is correct.
akhileshbc: Replace is an exception in VB6's functions, it always takes and returns a String, there is no Variant version of it.
-
Feb 9th, 2011, 04:09 AM
#12
Thread Starter
Junior Member
Re: Helo with a simple 'color code' thingy in vb6.
o_o um sorry there, but I have no idea how to use that :/
Never actually heard of it before...
-
Feb 9th, 2011, 06:16 AM
#13
Re: Helo with a simple 'color code' thingy in vb6.
 Originally Posted by Merri
akhileshbc: Replace is an exception in VB6's functions, it always takes and returns a String, there is no Variant version of it.
Ah! Thanks for the info 
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|