• We just launched and are currently in beta. Join us as we build and grow the community.

RichTextBox with Text Alignment in VB6

wefariwe64

Functional Programming Advocate
W Rep
0
0
0
Rep
0
W Vouches
0
0
0
Vouches
0
Posts
50
Likes
66
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
In this article, we will create a program that can open a RichTextBox and manipulate its alignment such as Left, Center, and Right. RichTextBox allows the user to enter and edit text while providing more advanced formatting features than the standard TextBox control. Text can be assigned directly to the control, or can be loaded from a rich text format (RTF) or plain text file.

Now, let's start this tutorial!

1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.

2.Go to Project Tab, and Click Components or Press Ctrl+T.

rtfcomponents.png


3. In the Controls Tab, find and check Microsoft Rich TextBox Control 6.0. Click apply and then click OK.

rtfcontrol.png


4. Next, insert two Buttons named cmdSearch labeled it as "Left",Command2 labeled it as "Center", and Command3 labeled it as "Right". Add also RichTextBox namedRich TextBox1 from the component. You must design your interface like this:

rtfdesign.png


5.Now put this code for your code module.
  1. Private

    Sub

    Command1_Click()
  2. RichTextBox1.SelAlignment = rtfLeft
  3. End

    Sub
  4. Private

    Sub

    Command2_Click()
  5. RichTextBox1.SelAlignment = rtfCenter
  6. End

    Sub
  7. Private

    Sub

    Command3_Click()
  8. RichTextBox1.SelAlignment = rtfRight
  9. End

    Sub

Explanation:

Button1 is used for the Left alignment, Button2 for Center Alignment, and Button3 for Right Alignment. The SelAlignment property of a RichTextBox returns a selected alignment of either left, center or right. rtfLeft will go to the text’s left alignment, rtfCenter will go to the text’s center alignment, rtfRight will go to the text’s right alignment, respectively.

Output:

rtfleft.png

rtfright1.png


Download the source code below and try it! :)

For more inquiries just contact my number or e-mail below.

Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09488225971
Telephone: 826-9296
E-mail:[email protected]

Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,341

323,350

Top