|
-
Dec 26th, 2006, 01:04 PM
#1
Thread Starter
Addicted Member
change color
i need to search a richtextbox for any text between << text >>
then change its color to blue including the word befor the brackets
example:
text befor searching
In all our MBA and MSc programmes, you can <<choose from a range>> of elective modules to personalise the content of your degree. Alternatively, you can follow one of <<our Specialisation>> Tracks to acquire a more focused set of skills and knowledge. This means that you can choose modules that are relevant to your <<needs today as well>> as those that will formalise your
text after searching
In all our MBA and MSc programmes, you can <<choose from a range>> of elective modules to personalise the content of your degree. Alternatively, you can follow one of <<our Specialisation>> Tracks to acquire a more focused set of skills and knowledge. This means that you can choose modules that are relevant to your <<needs today as well>> as those that will formalise your
-
Dec 26th, 2006, 01:19 PM
#2
Re: change color
You may want to read about moeur's RTB in CodeBank - http://vbforums.com/showthread.php?t=355994
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 3rd, 2007, 07:49 AM
#3
Thread Starter
Addicted Member
Re: change color
is there any simplist way to do it without using modules
because i'm new in VB and i need a simple code that i can understand
-
Jan 3rd, 2007, 09:47 AM
#4
Re: change color
Try
VB Code:
Dim i As Long
With RichTextBox1
For i = 1 To Len(.Text)
If Mid(.Text, i, 1) = "<<" Then
.SelStart = i
.SelLength = InStr(i, .Text, ">>") - i - 1
.SelColor = vbBlue
.SelBold = True
End If
Next
End With
-
Jan 3rd, 2007, 04:47 PM
#5
Thread Starter
Addicted Member
Re: change color
Hack 
it didn't work
whats the problem?
-
Jan 3rd, 2007, 05:16 PM
#6
Hyperactive Member
Re: change color
VB Code:
[B]Dim y As Integer[/B]
Dim i As Long
With RichTextBox1
For i = 1 To Len(.Text)
If Mid(.Text, i, 2) = "<<" And i > 2 Then
[B]y = InStrRev(.Text, " ", i - 2)[/B]
.SelStart = [B]y[/B] 'i - 2 -
.SelLength = InStr(i, .Text, ">>") -[B] y[/B] + 2
.SelColor = vbBlue
.SelBold = True
End If
Next
End With
Is what it should be like.
Last edited by Ember; Jan 3rd, 2007 at 05:34 PM.
-
Jan 3rd, 2007, 05:33 PM
#7
Re: change color
 Originally Posted by om-yousif
is there any simplist way to do it without using modules
because i'm new in VB and i need a simple code that i can understand
Omg... 
Module is the same as a Form - actually, better. If you declare a variable with a simple 'Dim' and you put it in a Module that variable is accessible from any module in your app (Form, Module, Class...). It's quite usefull to 'group' methods/functions also... And that's it - nothing more, nothing complicated and hard to understand.
Cheers
-
Jan 3rd, 2007, 05:36 PM
#8
Re: change color
@Ember: don't want to be critical, but... your code works in general (if you have "...blah blah <<blah>>..."). But there's a problem if you have only "<<blah" withouth ">>". You'll need to search for ">>" also before aplying the colour
-
Jan 3rd, 2007, 05:41 PM
#9
Hyperactive Member
Re: change color
 Originally Posted by gavio
@Ember:<<blah" withouth ">>". You'll need to search for ">>" also before aplying the colour 
I thought of it an d edited the code. Things like that can happen. Sorry!
-
Jan 3rd, 2007, 05:44 PM
#10
Re: change color
 Originally Posted by Ember
... Things like that can happen...
But of course
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
|