|
-
Feb 28th, 2004, 02:36 PM
#1
Thread Starter
Frenzied Member
Rich Text Box Highlighting
Okay, maybe some of you read my thread in chit-chat, maybe some of you didn't, but I've decided to start the program now and realized I know a lot less about rich text boxes than I thought I did. Is there a way to change the background color of certain numbers, or even just make them bold?? I plan on searching the rich text box for certain numbers or patterns of numbers but I want to have a way to highlight them to see if they form a pattern (to hopefully work on a theory of mine). Any help??
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 02:39 PM
#2
To highlight, you can use the SelStart and SelLength properties, unless I misunderstood you.
And bolding is easy (SelBold property), but changing the background only on certain text is tough. You can search the forum for the API's involved.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 28th, 2004, 02:41 PM
#3
Thread Starter
Frenzied Member
Can I select mulutiple non-sequential things though?? Im taking the first 10,000 digits of pi and searching it for certain numbers which will not be next to eachother. Maybe I should find a different way to do this??
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 02:42 PM
#4
-
Feb 28th, 2004, 02:52 PM
#5
Originally posted by Skitchen8
Can I select mulutiple non-sequential things though?? Im taking the first 10,000 digits of pi and searching it for certain numbers which will not be next to eachother. Maybe I should find a different way to do this??
Not all at once, no. But you could loop through and bold each part as you hit them.
Last edited by crptcblade; Feb 28th, 2004 at 02:59 PM.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 28th, 2004, 02:53 PM
#6
Originally posted by Michael_Kamen
Joe, don't help him.
Don't want him to win the nobel's price..
If there is cash involved, I'll do anything.
That's right, you heard me...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 28th, 2004, 02:58 PM
#7
Banned
Originally posted by crptcblade
If there is cash involved, I'll do anything.
That's right, you heard me...
Well, I know a few people with too much cash on their hands and lots of sickminded ideas..
-
Feb 28th, 2004, 03:08 PM
#8
Thread Starter
Frenzied Member
Originally posted by crptcblade
Not all at once, no. But you could loop through and bold each part as you hit them.
so maybe do a for next loop like
VB Code:
Dim i As Integer
For i = 1 To Len(rtf1.Text)
Next i
Wow... its been a long time since I've been here, and about the same amount of time since I've touched VB. I was at first thinking of using left$ or right$ to see if the character at position i equals whatever is in texthighl.text, but then I realized that those took all the characters left or right of position i. Then I thought i could use instr to find out if the character between i and i+len(texthighl.text) was what was in texthighl.text, but I can't seem to do that either. I am absolutely lost at the moment.
I tried to do "rtf1.Text = Replace(rtf1.Text, texthighl.text, "{\b" & texthighl.text & "\b0}")" thinking that I could just replace the characters with their bold equivalent in RTF code, but that doesn't work either, it just types out {\b.... in the box.
Wow, I figured this would be easy too...
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 03:16 PM
#9
Banned
Do you mean something like this?
VB Code:
Dim i As Integer
For i = 1 To Len(RTF1.Text)
If Mid(RTF1.Text,i, i +1) = CharacterIWantBold Then
'highlight character here
End
Next
-
Feb 28th, 2004, 03:17 PM
#10
-
Feb 28th, 2004, 03:24 PM
#11
Thread Starter
Frenzied Member
ding ding ding, mid is the function (errr... sub I guess) that I was looking for, thank you 
I still however cannot get it to work right with the following code (texthighl.text changed back to original text1.text because that is quicker to type).
VB Code:
Dim i As Integer
For i = 1 To Len(rtf1.Text)
If Mid(rtf1.Text, i, i + Len(Text1.Text)) = Text1.Text Then
rtf1.SelStart = i
rtf1.SelLength = 1
rtf1.SelBold
End If
Next i
It hangs up for a second while it is looping but it never ends up making anything bold, any help??
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 03:28 PM
#12
Thread Starter
Frenzied Member
Originally posted by Michael_Kamen
I'm still thinking about the hightlight section.. 
And I'm not sure if this is the most optimized way to do it.
I usually don't like If Statements in a Loop.
Especially not when that loop will run for about 10,000 times..
I know that its not very optimized, but since this program will be distributed only to me and anyone else that asks Im not chasing after optimization of code. If it works it works even if it takes 10 minutes to go through the loop.
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 03:33 PM
#13
Banned
Actually, this code does the trick:
VB Code:
Dim i As Integer
For i = 1 To Len(RTF1.Text)
If Mid(RTF1.Text, i, Len(Text1.Text)) = Text1.Text Then
RTF1.SelStart = i - 1
RTF1.SelLength = 1
RTF1.SelBold = True
End If
Next i
-
Feb 28th, 2004, 03:39 PM
#14
Thread Starter
Frenzied Member
You are a genius, if I ever win a nobel prize both of you are getting fair shares of it 
Although preliminary results are not turning up the patterns I was hoping for... this still needs a lot of work on my part to get it to different line lengths and looking for different things to be significant, but thank you so very much
Government is another way to say better…than…you.
It’s like ice but no pick, a murder charge that won’t stick,
it’s like a whole other world where you can smell the food,
but you can’t touch the silverware.
Huh, what luck. Fascism you can vote for.
Humph, isn’t that sweet?
And we’re all gonna die some day, because that’s the American way
-Stone Sour
-
Feb 28th, 2004, 03:40 PM
#15
Banned
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
|