Looking for the right control.

Posted on 2002-05-08
Last Modified: 2011-08-18

I need a control that I can use to display text with some formatting, e.g. text placement, bolding, etc.  The Rich Text control would do the job, I would think but I would prefer something more light weight.  

I know that the Picturebox control can display text but MSDN has very little info on this method, in fact it's not even listed under methods despite the fact that MSDN makes reference to the method.

I also will need to print the text displayed in whatever control I use.

Any ideas are appreciated.


Question by:syntel
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3

Expert Comment

ID: 6997212
The standard textbox supports all of the above things you mentioned...


With Text1
   .Alignment = 0 'left
   .Alignment = 1 'right
   .Alignment = 2 'center
   .FontBold = True
   .FontSize = 14
   .ForeColor = vbRed
End With

Hope this helps.

Accepted Solution

sodakotahusker earned 100 total points
ID: 6997253
You are right but I bet he wants selective bolding/coloring etc which requires something like rich text box because of its use of rtf formatting.  You can use print method on a picturebox to print multiple font types but it is not real easy since you have to control the entry point for the text.   Here is a sample:

Private Sub Form_Activate()
    Picture1.CurrentX = 500
    Picture1.CurrentY = 900
    Picture1.FontBold = True
    Picture1.ForeColor = vbGreen
    Picture1.Print "This is quite tedious"
    Picture1.CurrentX = 1500
    Picture1.CurrentY = 1900
    Picture1.FontItalic = True
    Picture1.ForeColor = vbRed
    Picture1.FontSize = 22
    Picture1.Print "Whatever "

End Sub

I use the richtext box control myself.  


Expert Comment

ID: 6997356
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

LVL 22

Expert Comment

ID: 6997574
I think sodakotahusker's got it, but understand that the picturebox is pretty heavyweight and also won't allow users to select the text.

However, you could make the task less tedious by creating a subroutine for it:

Private sub PrintText(TextToPrint as string, optional XPosition as double=-1, optional YPosition as double=-1, optional TextColor as long=-1, optional FontSize as single =0, optional MakeBold as boolean=false, optional MakeItalic as boolean=false)

if XPosition <> -1 then
  Picture1.CurrentX = XPosition
end if

if YPosition <> -1 then
  Picture1.CurrentY = YPosition
end if

if TextColor <> -1 then
  Picture1.Forecolor = TextColor
end if

if FontSize <> 0 then
  Picture1.Font.Size = FontSize
end if

Picture1.Font.Bold = MakeBold
Picture1.Font.Italic = makeItalic

Picture1.Print TextToPrint;
end sub

' Now this is more manageable
Private Sub Form_Activate()
   PrintText "This is quite tedious", 500, 900, vbGreen, , True
   PrintText "Whatever ", 1500, 1900, vbRed, 22, , True
End Sub
LVL 16

Expert Comment

ID: 6997644
I recommend you that stick with Richtextbox. If we need great funcionality, we must "pay" for it.
There is a thin line between performance, easy to use, memory usage, disk space, etc.
We have to decide if it worth.

Author Comment

ID: 6998233
Thanks for the replies!

I do want selective bolding, color, etc, but I only need to display the text and print it.

How much 'weight' does the Richtextbox use as compared to the picturebox?  I did not find the examples of the Print method in MSDN - did I miss it?


LVL 16

Expert Comment

ID: 6998679
did you think to show formatted plain text using HTML?
Webbrowser is huge (i know that!) but it is in almost every OS Windows on this planet.
LVL 22

Expert Comment

ID: 6999193
The Print command is not in MSDN because it is a "straggler" from the days of QuickBASIC and MS wasn't sure exactly how to support it in the first VB iteration.  They continued to support it by having the window (and also picturebox) become the print area, but apparently decided that it's better supported by dropping objects at the desired places.

As for weight, I think that the RichTextBox is a spin-off of the picturebox and has since had additional features added that made it "heavier."  The reason it's hard to tell is because although the RichTextBox is a separate component (RICHTX32.OCX) at 200K, the PictureBox is part of the standard VB package which includes many other controls and the VBA engine (MSVBVM60.dll) at 1356K.

Author Comment

ID: 7000413
Thanks all.  I will probably go with the picbox.

Thanks again,


Author Comment

ID: 7000994
Anyone know if the RichTextBox can do lines?  The PictureBox does - what about the RTB?  

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month6 days, 11 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question