Access the database directly in the VB

xiaoxiao2021-03-06  51

In VB with ODBC API to access the database directly Author: Wu Bin from WINDOWS 95, Microsoft offers an easy to use file finder for us. Using this search, we can easily quickly find the eligible file. But sometimes we also need this feature in programming, can you implement it in your own procedure? The answer is of course affirmative. Below we come to design a file searcher in a VB program. First, enter VB to create a new form. Create a driver list box (DRIVELIST), a directory list box (FolderList), a check box (FileName, FileSize), and Two Buttons (FileName, FileSize), cmdexit). It is important to note that the ListView control is part of a group of ActiveX controls in the mscomctl.ocx file. To use the ListView control in your application, you must add the MScomctL.ocx file to the project. Select the listView control, click the right mouse, select "Properties" in the pop-up menu. Set the columns to be displayed in the "List" page of the attribute window, press "Insert Column" 5 times.

Good control of the position of each arrangement, and then adding the following code: Option Explicit Dim FileSys As Scripting.FileSystemObject Private Sub CmdExit_Click () End End Sub Private Sub DriveList_Change () FolderList.Path = DriveList End Sub Private Sub Form_Load () Dim I As Integer Set FileSys = New Scripting.FileSystemObject FolderList.Path = Left (DriveList.Drive, 2) & "" With FileList.ColumnHeaders.Item (1) .Alignment = lvwColumnLeft .Text = "filename" .Width = 2000 End With With FileList. ColumnHeaders.Item (2) .Alignment = lvwColumnRight .Text = "size (KB)" .Width = 1500 End With With FileList.ColumnHeaders.Item (3) .Alignment = lvwColumnLeft .Text = "type" .Width = 1500 End With with FileList.ColumnHeaders.Item (4) .Alignment = lvwColumnLeft .Text = "path" .Width = 2000 End with with FileList.ColumnHeaders.Item (5) .Alignment = lvwColumnLeft .Text = "modified" .Width = 2000 End WITH End Sub Private Sub Form_Unload (Cancel As Integer) Set Filesys = Nothing End Sub Private Sub Cmdsearch_Click () Dim Sfolderstart As Scripting.Folder Set Sfolderstart = FileSys.get Folder (FolderList.Path) filelist.listitems.clear addfiles sfolderstart if filelist.listitems.count = 0 THEN MSGBOX _ "Did not find any qualified files! ", VbOKOnly vbInformation," message "End Sub Private Sub AddFiles (SFolderSearch As Scripting.Folder) Dim SFolder As Scripting.Folder Dim SFile As Scripting.File Dim sngFileSize As Single Dim lngSize As Long Dim Itm As ListItem If SubCheck.Value = 1 Then if Sfoldersearch.Subfolders.count The for Each Sfolder In Sfoldersearch.Subfolders AddFiles Sfolder Next Sfolder End if end if SngfileSize =

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

New Post(0)