1 Displaying Dialog Boxes Kashef Mughal
2 Midterm Stats Here we go Average was Low was 116 High was 184 Mid Quarter Grade - check any mistakes Questions # 38, 67 and 93 Only 40% in still have 60% to go Any questions
3 Dialog Boxes There are six main types of dialog boxes in VB.NET MessageBox (most important) Open Save Font Color Print
4 MessageBox Dialog Used to give some type of message to the user Also is a good tool to debug your code Uses a bunch of parameters Syntax is MessageBox.show (text, caption, buttons, icon, default button)
5 Parameter Details Text is the only required parameter and it represents the message that will be displayed caption is the text displayed in the title bar buttons represents the number of buttons displayed in the dialog box - more on page 315 icon is displayed to enhance the effect of message default button lets you specify the default button
6 More on MessageBoxes .SHOW is the method used to display the dialog MessageBox is actually a function that returns a result defined by DialogResult enumeration - more on Page 317 VB6 used Msgbox function which does the same thing. It is acceptable to use either one Keep the use of message boxes to a minimum Try the exercises on Pages
7 File Types Files to which information is written are called output files, because the files store the output produced by an application Files that are read by the computer are called input files, because an application uses the information in these files as input Here is a list of different file types: Sequential access files Random access files Binary access files
8 Using Sequential Access Files A sequential access file is often referred to as a text file, because it is composed of lines of text Sequential access files are similar to cassette tapes in that each line in the file, like each song on a cassette tape, is both stored and retrieved in consecutive order (sequentially)
9 Procedure for Using a Sequential Access File 1.Declare either a StreamWriter or StreamReader object variable 2.Create a StreamWriter or StreamReader object by opening a file; assign the object’s address to the object variable declared in Step 1 3.Use the StreamWriter object to write one or more lines of text to the file, or use the StreamReader object to read one or more lines of text from the file 4.Use the StreamWriter or StreamReader object to close the file
10 Using StreamWriter and StreamReader Objects In Visual Basic.NET Use a StreamWriter object to write a sequence of characters—referred to as a stream of characters or, more simply, a stream—to a sequential access file Use a StreamReader object to read a stream (sequence of characters) from a sequential access file Before you create the appropriate object, you first must declare an object variable to store the address of the object in the computer’s internal memory
11 Open Dialog Used to open files Has a number of methods and properties - more on Pages The Open Dialog works with the StreamReader object to read data from a file StreamReader has a few methods as shown on Page 327
12 Save Dialog Used to save files Has a number of methods and properties - more on Page 333 The Open Dialog works with the StreamWriter object to write data to a file Try the following exercises 327 and 335
13 Font and Color Dialogs Font dialog lets you change surprising the font in an application It uses the default Window font dialog box to do this Color dialog lets you change the color of the forms It also uses the default Window font dialog box to do this
14 Print Dialogs This dialog lets you print data from a VB application Definitely good to know this one Will also employee the Windows default printer dialog box Using the methods and properties, you can control the behavior of the print dialog Employs the PrintDocument class
15 More Hands on Try the following exercises 341 346 350 Next week Chapters 9 and 10