?? frmshahida.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3180
ClientLeft = 165
ClientTop = 750
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3180
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 2175
Left = 0
TabIndex = 4
Top = 0
Width = 4695
_ExtentX = 8281
_ExtentY = 3836
_Version = 327680
End
Begin VB.Frame Frame1
Caption = "Search for "
Height = 735
Left = 0
TabIndex = 1
Top = 2280
Width = 4575
Begin VB.CommandButton Command1
Caption = "&Search"
Height = 375
Left = 2640
TabIndex = 3
Top = 240
Width = 1815
End
Begin VB.TextBox Text1
Height = 375
Left = 120
TabIndex = 2
Text = "Text1"
Top = 240
Width = 2295
End
End
Begin VB.ListBox List1
Height = 2205
Left = 0
TabIndex = 0
Top = 0
Width = 4695
End
Begin VB.Menu mnuView_
Caption = "&View"
Begin VB.Menu mnuView
Caption = "&Simple"
Index = 1
End
Begin VB.Menu mnuView
Caption = "&Extended"
Index = 2
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' example for Shahid Majed
' concerning VB & Access
' KATHER Produkties 24 feb 1998
'
' DON'T FORGET TO CHANGE THE RIGHT PATH! (see form_load)
' also checkout the MS Access section on the site
' http://pi1438.kub.nl:2080/VisualBasicSource/
' it's all there!
Const DBName As String = "biblio.mdb"
Dim strPath As String
Dim db As Database
Dim rsTitles As Recordset
Dim strSQl As String
Dim blnView As Boolean
Const MeWidth As Integer = 4800
Const MeHeight As Integer = 3885
Private Sub Command1_Click()
Dim rs As Recordset
Dim intRow As Integer
'if there is nothing to search for then exit
If Text1.Text = "" Then Exit Sub
Screen.MousePointer = vbHourglass
'check the kind of view
If blnView Then
List1.Visible = True
MSFlexGrid1.Visible = False
List1.Clear
'make the search
strSQl = "SELECT * FROM Titles"
strSQl = strSQl & " WHERE title LIKE '*" & Text1.Text & "*'"
Else
List1.Visible = False
MSFlexGrid1.Visible = True
MSFlexGrid1.Clear
MSFlexGrid1.TextMatrix(0, 0) = "Title"
MSFlexGrid1.TextMatrix(0, 1) = "Author"
MSFlexGrid1.TextMatrix(0, 2) = "ISBN"
'make the search
strSQl = "SELECT Titles.Title, Authors.Author, Titles.ISBN"
strSQl = strSQl & " FROM Titles INNER JOIN (Authors INNER JOIN [Title Author] ON Authors.Au_ID = [Title Author].Au_ID) ON Titles.ISBN = [Title Author].ISBN"
strSQl = strSQl & " WHERE (((Titles.Title) Like '*" & Text1.Text & "*'))"
End If
'show the found records
Set rs = db.OpenRecordset(strSQl)
If Not (rs.BOF And rs.EOF) Then
Do While Not rs.EOF
'depends on the kind of view
If blnView Then
List1.AddItem rs.Fields(0).Value
Else
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = rs.Fields(0).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = rs.Fields(1).Value
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = rs.Fields(2).Value
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
End If
rs.MoveNext
Loop
End If
'show number of records found
Me.Caption = CStr(rs.RecordCount) & " records found"
'close the recordset
rs.Close
Screen.MousePointer = vbNormal
End Sub
Private Sub Form_Load()
'change the path!
strPath = "c:\program files\devstudio\vb\"
'open the database
Set db = OpenDatabase(strPath & DBName)
'open the recordset
Set rsTitles = db.OpenRecordset("Titles")
'show all records (titles)
Do While Not rsTitles.EOF
List1.AddItem rsTitles.Fields(0).Value
rsTitles.MoveNext
Loop
'setup the grid
MSFlexGrid1.Visible = False
MSFlexGrid1.Cols = 3
MSFlexGrid1.FixedCols = 0
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.AllowUserResizing = flexResizeColumns
MSFlexGrid1.ColWidth(0) = MSFlexGrid1.Width / 3
MSFlexGrid1.ColWidth(1) = MSFlexGrid1.Width / 3
MSFlexGrid1.ColWidth(2) = MSFlexGrid1.Width / 3
'setup the listbox
List1.Visible = True
'setup the view
blnView = True
mnuView(1).Checked = True
'finished it up
Text1.Text = ""
Me.Caption = "Demo"
Me.Show
End Sub
Private Sub Form_Resize()
'if minimized then exit
If Me.WindowState = vbMinimized Then Exit Sub
'if lower the standard values reset
If Me.Height < MeHeight Then Me.Height = MeHeight
If Me.Width < MeWidth Then Me.Width = MeWidth
'setup list1 & msflexgrid1
Form1.Scale
Frame1.Move 50, Form1.Height - Frame1.Height - 800
If blnView Then
List1.Height = Form1.Height - Frame1.Height - 800
List1.Width = Form1.Width
List1.Move 0, 0
Else
MSFlexGrid1.Height = Form1.Height - Frame1.Height - 800
MSFlexGrid1.Width = Form1.Width
MSFlexGrid1.Move 0, 0
MSFlexGrid1.ColWidth(0) = MSFlexGrid1.Width / 3
MSFlexGrid1.ColWidth(1) = MSFlexGrid1.Width / 3
MSFlexGrid1.ColWidth(2) = MSFlexGrid1.Width / 3
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
'close all open recordset you have forgotten and the end the application
Close
End
End Sub
Private Sub mnuView_Click(Index As Integer)
Select Case Index
Case 1 'simple vieuw with listbox
blnView = True
mnuView(2).Checked = False
mnuView(1).Checked = True
Case 2 'extended view with grid
blnView = False
mnuView(2).Checked = True
mnuView(1).Checked = False
End Select
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -