VISUAL BASIC_6
 

Running the Project:

Select Start from the Run Menu.   You will find the Common dialog box has become invisible in the run mode window.   The run mode window appears as in the figure 2. On clicking the open button, you will get the open dialog window as in the figure 3.   Click the cancel button in the open dialog window .  Now click the Save button to view the Save window.   Repeat this for viewing all the other windows and see that the project is successful..


                                              Figure 2

 


                                                Figure 3

2. Project using RichTextBox Control:

The traditional text box control is ideal for text entry at a given font and size.   RichTextBox Control  allows the user to enter text with varying fonts and sizes.   Add the RichTextBox control and the Common Dialog Control to the Toolbox by drawing them from the component dialog box.  Drag a RichTextBox control, Common Dialog Control  and a Command Btton control in the form.   Set the command button caption and name as font.   A font dialog box can be opened only through the Common Dialog control.   The Common Dialog control box will be invisible during run time. .Save the form and the project.    The project at the design time looks as in the figure 4.


                                                      Figure 4

Entering the Code:

Open the code window by double clicking the font button.   Enter the codes as shown in the figure 4a and finally save the project.

Private Sub Font_Click()

'Show both printer and screen fonts

CommonDialog1.Flags = cdlCFBoth

CommonDialog1.ShowFont

RichTextBox1.SelFontName = CommonDialog1.FontName

RichTextBox1.SelFontSize = CommonDialog1.FontSize

RichTextBox1.SelBold = CommonDialog1.FontBold

RichTextBox1.SelItalic = CommonDialog1.FontItalic

RichTextBox1.SetFocus

End Sub

             Figure 4a

Running the Project:

Select Start from the Run menu.   You type any text in the RichTextBox and select it.   Click the font button.   The font dialog box will open.   Set the desired font and size.   On deselecting

the text, you will find the text printed in the desired font and size.   The run mode window is shown in the figure 5.


                        Figure 5


 

Copyright © 2001 Selfonline-Education. All rights reserved.