Visual Basic Design Graphical Browser Example

zhaozj2021-02-11  182

Visual Basic Design Graphical Browser Example

Want to design a graphic browser? In fact, this is not difficult, we can easily use VB programming. The design process of the graphics browser is as follows: 1. Start VB, create a new standard engineering file, on the form FORM1, change the CAPTION = "Graphical Browser" of Form1. 2. From the toolbox, add the drive, folder, and file control into the form, the name of the drive is Diver1, the folder's name is DIR1, the file's Name is file1, and adjusts the appropriate location. 3. Add the Picture Box control from the toolbox to the form, the name Box of the Picture Box is Picture1, and adjusts the appropriate location, high width. 4. From the toolbox, add the Command Button control to the form, Command Button's Name is Command1, and adjusts the appropriate location, high width. 5. Double-click the mouse in the blank of the form, pop up the code editing window, enter the following code: Private Sub form_load () Set the drive and directory of the application to the current drive and directory 'app is the current application object Drive1.Drive = app .Path dir1.path = app.path file1.pattern = "* .bmp; *. ICO; *. WMF" end SUB 6. Double-click the mouse on the list of drive controls, pop up the code editing window, enter the following code: Private Sub DRIVE1_CHANGE () 'When the driver changes, update the content in the directory list box; the directory changes, trigger the directory list box, Dir1.Path = Drive1.drive End Sub 7. Double-click the mouse on the folder control of the form. Pop-up code editing window, enter the following code: Private sub Dir1_change () 'Directory changes, update the content file1.path = dir1.path End Sub 8 on the file list in the form of the file, pop up the code editing window Enter the following code: Private sub file1_click () 'When the root directory, the last character in the path is a backslash "/", such as: c: /' Non-root directory, the last character in the path is not a backslash "/" 'Get the full file name, should be in the last plus backslash "/" if right (file1.path, 1) <> "/" the' non-root directory, plus the last plus A backslash "/" tempstring = file1.path && "/" && file1.filename else tempstring = file1.path && "/" && file1.filename end iF 'loaded into selected files Form1.Picture1.Picture = loadingPicture (TEMPSTRING) End Sub 9. Double-click the mouse on the "Close" control of the form, pop up the code editing window, enter the following code: private submmand1_click () unload me end and save the file and run, your own graphics browser design All right.

转载请注明原文地址:https://www.9cbs.com/read-4872.html

New Post(0)