Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] Common Dialogs
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
diqua




PostPosted: Tue Oct 25, 2005 9:21 pm   Post subject: [Tutorial] Common Dialogs

Since i found it a real pain finding out how Common Dialogs work im going to try and explain what ive learned

In VB common dialogs are used to show common looking screens through out the whole program to keep with the windows feel.

The Common Dialogs are the windows such as the Open/Save dialog, the Printing Dialog, as well as the Color and Font select dialogs.

To use common dialogs you must add the control to the form, but first you have to add it to the tool box by right clicking on the tool box and selecting components. After that select "Microsoft Common Dialog Control 6.0" and it should add it.

for use in my examples the common dialog control will be called cdlTest

to open the dialogs you use the following code

code:
cdlTest.ShowOpen 'Shows the Open dialog
cdlTest.ShowSave 'Shows the Save Dialog
cdlTest.ShowFont 'Shows the Font Select Dialog
cdlTest.ShowColor 'Shows the Color Select Dialog
cdlTest.ShowPrinter 'Shows the Printer Dialog
cdlTest.ShowHelp 'Shows the Help Dialog


Some basic Properties:

Color returns the color code of the color chosen through the Color Select Dialog
FileName returns or sets the path and filename of a selected file in the Save/Open Dialog
InitDir returns or sets the starting directory for a Save/Open Dialog

Example:
code:
Option Explicit

Sub OpenFile()
dim strPath as string, strInput as string
cdlTest.ShowOpen 'Opens the Open Dialog
strPath = cdlTest.FileName 'Gets the path from the Dialog
open strPath for input as #1 'Opens the file for reading
do until eof(1) 'reads until the end of the file (EOF)
input line #1, strInput 'reads a line of text and sends it to strInput
txtOutput.text = txtOutput.text & strInput 'then it is displayed in a text box
loop
close 1
end sub


Any Questions feel free to message me
Diqua
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Oct 26, 2005 9:34 am   Post subject: (No subject)

that could be useful, thx +Bits
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: