Library tutorials & articles
Rich Text Box Controls
- Introduction
- Basic Formatting
- Inserting text
- Indents & Aligning
- Colors, bullets & superscript
Colors, bullets & superscript
First there's coloring. You set this by changing the SelColor to the color
of your choice. You can use any color (vbcolor, RGB, QBColors).
Object.SelColor = color
RichTextBox1.SelColor = vbGreen
'Now anything typed will be green
Now protecting. Protecting disabled editing from the selected text
Object.SelProtected
RichTextBox1.SelProtected = True
Any text that was selected during this method is now protected.
Bullets are creating by setting the SelBullet property to true. This creates
bullets where new lines are put, and the line the cursor was just at.
Object.SelBullets = True
'RichTextBox displays:
'We are know for:
'Creating programs
RichTextBox.SelBullets = True
'RichTexBox now displays
'We are know for:
'·Creating programs
With the bullets you can indent them using BulletIndent
Object.BulletIndent = Integer
'Using the one before
'RichTextBox1 displays:
'We are know for:
'·Creating programs
RichTextBox1.BulletIndent = 200
'RichTextBox1 no displays:
'We are know for:
'· Creating programs
Next is how to superscript or subscript. To make superscript or subscript you
have to use the SelCharOffSet and SelFontSize at the same time. The SelCharOffSet
just changes the position of the text.
Using the SelCharOffSet property:
Object.SelCharOffSet property
To subscript, you just need to change the SelFontSize. If
you want to superscript, you must change the font size and the SelCharOffSet.
Hello
SubScript:
Dim VariableName As Integer
Integer = Object.SelFontSize
Object.SelFontSize = Integer / 3 * 2
'This makes the size 2/3 of the original
SuperScript:
Dim VariableName As Integer
Object.SelFontSize = Integer / 3 * 2
Object.SelCharOffSet = Temp * 5
That is how you can make a subscript or superscript font. They covers most
of the control on the rich textbox.
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
hmm...anyone know how to code the button "aligement left" , so that when the button is clicked , the text in the richtextbox is align to the left...anyone can help? ~.^
!--removed tag-->hi redstar...
m also facing same problem.. do u got any solution?
with regards,
kailas
how to get arrow intendation
how to chane the bullet intend as arrow
I am wondering if thier is a way to save and load text formatting using VB6, for example fonts, text colors etc. Does anybody know any easy ways round it???
Try the following code as work around:
' flag the section with bullet mark
rtfSectionText.SelBullet = True
' replace bullet with numbers
rtfSectionText.SelRTF = Replace(rtfSectionText.SelRTF, "\pnlvlblt", "\pndec", 1, -1, vbTextCompare)
I found som rtf documentation on the Microsoft site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/html/rtfspec_16.asp
Hope it helps
Bulleted indenting is fine.
But how to get number indentation?
Is there any way?
thank you
How to make subscripts and superscripts in DHTML editor using c#?
Hi,
I am having problems in sending selected text to a rich text box control without selecting the text at runtime e.g. at runtime the rich text box contains the text "Selection" and when a command button is pressed the following text in BOLD is appended to the current text "IS EASY"
Selection IS EASY
(I know that this cannot).
I use the rich text box and insert in it the mschart object, but i can not refer to mschart property and metods with OLEOBJECTS.
help me pleas, help.
0 = rtf
1 = text
Hi,
i am working with richtextbox quite a lot of time, but i am still wondering how can i input a picture in it. Also i have the point that i ignore some of his opportunities. So i would be glad if you could write something about them. Thank you on advance
Object.Save (FilePath, FileType)
WHAT FILETYPES? Can it save in RTF, Text, and what are the corresponding numbers?????????????
Secondly, I am sure that in EVERY rich text editor I have ever used, you can set different indents for different paragraphs. Yet you do not mension how to align a paragraph... "is just like setting the alignment for a whole textbox."
Aside from that it was pretty good, but can't you also do Horizontal Rules in Rich Text? I know no-one normally does, but if ya can . . .
Thanks for the info though, I was always confused about the select stuff.
Hello KillerSheep,
Is this what you're looking for:
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Option Explicit
Public Const WMUSER = &H400
Private Const EMSETTARGETDEVICE = (WM_USER + 72)
Public Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal LParam As Long) As Long
Public Enum ViewModes
Default = 0
WordWrap = 1
WYSIWYG = 2
End Enum
Const EMFORMATRANGE As Long = WMUSER + 57
'** Set View Mode
Public Sub SetViewMode(ByVal ViewMode As ViewModes)
Select Case ViewMode 'Set View Mode
Case 0 'No Wrap
SendMessageLong rtfText.hWnd, EMSETTARGETDEVICE, 0, 1
Case 1 'Word Wrap
SendMessageLong rtfText.hWnd, EMSETTARGETDEVICE, 0, 0
Case 2 'WYSIWYG
On Error Resume Next
SendMessageLong rtfText.hWnd, EM_SETTARGETDEVICE, Printer.hdc, Printer.Width
End Select
End Sub
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
By
Thanks a lot!
Now, where can I find the soln for this?
VB has no bulit in functions or constants for what you want, im not gonna be much help here sorry!
Not left, right or center.
Justified as in MS Word. ie, both left and right ends are aligned.
and one of the following;
for example;
RichTextBox1.SelAlignment = vbCenter
or
RichTextBox1.SelAlignment = vbLeftJustify
Hope thats some help;
Luke
When printing Rich Textbox text it seems to disregard the Current X/Y command. What gives>
Could you tell me how to display the text in Justified manner in a RT Box?
I've tried just about everything (other than writing a new control
Tx and Regards
one thing you forgot - How do you toggle line wrapping on and off?!
hee hee thanks
There is no option of
Richtextbox1.selprint(Printer.hdc) in vb.net that is only in VB6.
Thanks
'Prints the current document using the device
'handle of the current printer
RichTextBox1.SelPrint (Printer.hDC)
End Sub
This thread is for discussions of Rich Text Box Controls.