the common dialog box. installing the common dialog box may not be your standard vb toolbox
TRANSCRIPT
![Page 1: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/1.jpg)
The Common Dialog Box
![Page 2: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/2.jpg)
Installing the Common Dialog Box
May NOT be your standard VB toolbox.
![Page 3: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/3.jpg)
Step 1:Select Components from the Project Menu
![Page 4: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/4.jpg)
Step 2: Check Microsoft CommonDialog Control 6.0
![Page 5: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/5.jpg)
The Many Methods of the Dialog Box
Open File .ShowOpen
Save File .ShowSave
Color .ShowColor
Print .ShowPrinter
Help .ShowHelp
![Page 6: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/6.jpg)
Common Dialog (Example)
Interface
![Page 7: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/7.jpg)
Set the Properties
txtDisplay cmdOpenFile cmdSaveFile cmdFont cmdPrint cmdTextColor cmdBackColor
![Page 8: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/8.jpg)
Write the Code: Error Checking
CommonDialog1.CancelError = False On Error GoTo FontError ‘where to go…The code goes here… and here
FontError: ‘this is a labelExit SubFontError:End Sub
![Page 9: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/9.jpg)
The Font Dialog: Flags
The of the Common Dialog box uses other flags to control behaviors. The Font dialog Flags property must be set to the value 1 to load the system fonts.After the font dialog box appears and selections are made, the values the user selected are available to the program.
![Page 10: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/10.jpg)
Font Psuedocode
Set Cancel Error flag to 1Error handlerSet Flags property to 1Display the dialog boxSet font properties for bold, italic, font
strike through font size, font name, and properties of text box (example: txtFontBold = CommonDialog1.FontBold)
![Page 11: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/11.jpg)
Shortcut Rather than typing txtFontBold = CommonDialog1.FontBoldtxtFontItalic = CommonDialog1.FontItalicEtc.Use the shortcutWith txtDisplay.Font
.Bold = CommonDialog1.FontBold
.Italic = CommonDialog1.FontItalicetc.
End With
![Page 12: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/12.jpg)
Font CodeCommonDialog1.CancelError = FalseOn Error GoTo FontErrorWith CommonDialog1
.FontName = txtWord.FontName
.Flags = 1
.ShowFonttxtWord.Font.Name = .FontNametxtWord.FontBold = .FontBoldtxtWord.FontItalic = .FontItalictxtWord.FontSize = .FontSize
End WithExit SubFontError:
![Page 13: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/13.jpg)
The Color Dialog
set CancelError to trueError handlerdisplay the color dialog boxset the text box property (eitherBackColor or ForeColor) to CommonDialog1.ColorError routine: no code needed.
![Page 14: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/14.jpg)
How Files Work
Buffer Disk Drive
Computer
![Page 15: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/15.jpg)
The Open File Dialog
Filter begins and ends with a quote marks. The pipe | is used as a separator.
"Text Files (*.txt) | *.txt| All Files (*.*) |*.*|HTML Files (*.htm)|*.htm*"
![Page 16: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/16.jpg)
The Open Dialog:Getting the File Name
With CommonDialog1set the filterset the Filter index = 1display Open common dialogset FileName to .FileName
End With
![Page 17: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/17.jpg)
The Open Dialog:Reading the File
Declare integer for bufferAssign bufferOpen the file (FileName) For
InputRead in the whole file
Input(LOF(F), F to the text boxClose the file
![Page 18: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/18.jpg)
Open Dialog: CodeOn Error GoTo OpenErrorDim F As IntegerF = FreeFileCommonDialog1.CancelError = TrueCommonDialog1.Filter = "Text Files (*.txt)|
*.txt| Web Files (*.htm)|*.htm" CommonDialog1.ShowOpenOpen CommonDialog1.FileName For Input As FtxtWord.Text = Input(LOF(F), F)Close #F
![Page 19: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/19.jpg)
Saving A FileSet Cancel ErrorError HandlerDim F for buffer numberset the filterset the filter index to 1show the save boxset file name to dialog box file nameOpen the file for outputPrint #F, txtWord.TextClose the fileF
![Page 20: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/20.jpg)
The Print Dialog
CommonDialog1.ShowPrinter Some of the properties returned are:
FromPage ToPageToPage Copies
![Page 21: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/21.jpg)
To Print
Use the object's Print method
Printer.Print <what you want printed>
Printer.EndDoc To print the contents oftext boxPrinter.Print txtWord.TextPrinter.EndDoc
![Page 22: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/22.jpg)
Save or Save As?
If (the file has a name)save using the filename
elseshow the Save dialog
End If
![Page 23: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/23.jpg)
You must:
Form_Load - Set FileName to "“mnuSaveAs - Set FileName to CommonDialog1.FileName mnuOpen - Set FileName to CommonDialog1.FileName mnuNew - Set FileName to ""
![Page 24: The Common Dialog Box. Installing the Common Dialog Box May NOT be your standard VB toolbox](https://reader036.vdocuments.us/reader036/viewer/2022062518/56649e7f5503460f94b82b76/html5/thumbnails/24.jpg)
And in conclusion…
You should now be able to add save, save as, open, print, and set font to your word processor!