120 likes | 209 Views
Chapter 8 : Security, Menus, and Files. Passwords are often used to control access to a computer or software program. Passwords should be at least 6 characters in length and something that cannot be easily guessed.
E N D
Chapter 8:Security, Menus, and Files Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Passwords are often used to control access to a computer or software program. Passwords should be at least 6 characters in length and something that cannot be easily guessed. It should not be possible to move, resize, or bypass the password form in VB and it should be the Startup object. The Tag property for a textbox can be used for the password and the PasswordChar property can be used to disguise the password as it is entered. A user should be given a set number of “chances” to enter the correct password. Security Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
A menu system for a form can be created using the Menu Editor. Menu bar options as well as submenus can be created with this editor. Menu and submenu items have caption and name properties (the prefix is mnu). Code is written for menu items just like for other event procedures. Menu options are always click events. Most menus contain File and Help menu bar options in addition to others specific to the application. Menu Systems in VB Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Menu Editor Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Creating a memo editor in VB involves using a textbox as the location of the text and a menu system for the various editor commands. The textbox should have its MultiLine property set to true and its ScrollBars property set to vertical. The Form_Resize event occurs when the user displays a textbox--it can be used to cause the memo text box to fill its form by setting the Height and Width properties to ScaleHeight and ScaleWidth. Creating a Memo Editor Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
The File Menu should have options to begin a new memo, open an existing memo, save a memo under the current name or a new one, close the memo, print it, or exit the memo editor. Key to the File Menu is the use of the common dialog control which must be added to the Toolbar with the Project|Components VB menu option before being added to the form. The common dialog control (with dlg prefix) can be used to open or save files with the ShowOpen and ShowSave methods. The Memo Editor File Menu Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Plan for Vintage Videos Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
The Filter property of the common dialog control is used to display a list of files. It has the form: dlgName.Filter = “description1|filter1|description2|filter2|etc” The FilterIndex property determines the default file type. When a file is selected or a filename entered, this becomes the Filename property for the dialog box. The FreeFile function returns an unused file number and the On Error Goto statement causes control to jump to a label when an error is encountered. Both are useful in working with files. Saving a Memo Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
A file can be opened from a common dialog box with the ShowOpen method. The contents of the file can be input using the Input$ function: Input$(number, #filenumber) where number = number of characters in file that is identified by #filenumber. The LOF(FileNumber) function can be used to determine the number of characters in a file. A memo can be saved by printing its contents to a file—it is common to query the user to save the file if it has been changed. Other File Operations Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Typical editing options are Cut, Copy, and Paste. All three use the Clipboard object to temporarily save information. The Clipboard SetText method transfers selected text to the clipboard and the GetText method retrieves text from clipboard. The Clipboard Clear method clears the Clipboard. The Memo Editing Submenu Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Using the Clipboard Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy
Formatting of text in the memo involves changing the Font and Style of the text. Menu control arrays are used to display different types of fonts and styles. The FontName property of the memo textbox determines the font type. FontBold, FontItalics, FontUnderline properties of the textbox control the style of the text. The Memo Format Submenu Introduction to Programming with Visual Basic 6.0 by McKeown and Piercy