home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "THREED32.OCX"
- Begin VB.Form Form1
- Caption = "List Search"
- ClientHeight = 3915
- ClientLeft = 2400
- ClientTop = 1650
- ClientWidth = 6990
- LinkTopic = "Form1"
- ScaleHeight = 3915
- ScaleWidth = 6990
- Begin VB.CommandButton DeleteButton
- Caption = "Delete"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 3000
- TabIndex = 2
- Top = 3240
- Width = 1215
- End
- Begin VB.CommandButton AddButton
- Caption = "Add New"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 5640
- TabIndex = 1
- Top = 3240
- Width = 1215
- End
- Begin VB.ListBox List1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 3450
- Left = 120
- Sorted = -1 'True
- TabIndex = 0
- Top = 240
- Width = 2655
- End
- Begin VB.CommandButton CancelButton
- Caption = "Cancel"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 3000
- TabIndex = 4
- Top = 3240
- Width = 1215
- End
- Begin VB.CommandButton OKButton
- Caption = "OK"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 5640
- TabIndex = 3
- Top = 3255
- Width = 1215
- End
- Begin Threed.SSPanel SSPanel1
- Height = 2775
- Left = 2880
- TabIndex = 5
- Top = 240
- Width = 3975
- _Version = 65536
- _ExtentX = 7011
- _ExtentY = 4895
- _StockProps = 15
- BackColor = 12632256
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- BevelOuter = 1
- BevelInner = 1
- Begin VB.TextBox Text1
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 120
- TabIndex = 9
- Top = 480
- Width = 1665
- End
- Begin VB.TextBox Text2
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 2040
- Locked = -1 'True
- TabIndex = 8
- Top = 480
- Width = 1725
- End
- Begin VB.TextBox Text3
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 315
- Left = 120
- Locked = -1 'True
- TabIndex = 7
- Top = 1200
- Width = 3660
- End
- Begin VB.TextBox Text4
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 675
- Left = 120
- Locked = -1 'True
- MultiLine = -1 'True
- TabIndex = 6
- Top = 1905
- Width = 3645
- End
- Begin Threed.SSPanel SSPanel2
- Height = 255
- Left = 120
- TabIndex = 10
- Top = 240
- Width = 1215
- _Version = 65536
- _ExtentX = 2143
- _ExtentY = 450
- _StockProps = 15
- Caption = "I S B N"
- BackColor = 12632256
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9.01
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- BevelOuter = 0
- Font3D = 3
- Alignment = 1
- End
- Begin Threed.SSPanel SSPanel3
- Height = 255
- Left = 2010
- TabIndex = 11
- Top = 240
- Width = 1215
- _Version = 65536
- _ExtentX = 2143
- _ExtentY = 450
- _StockProps = 15
- Caption = "Published by"
- BackColor = 12632256
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9.01
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- BevelOuter = 0
- Font3D = 3
- Alignment = 1
- End
- Begin Threed.SSPanel SSPanel4
- Height = 255
- Left = 120
- TabIndex = 12
- Top = 960
- Width = 1095
- _Version = 65536
- _ExtentX = 1931
- _ExtentY = 450
- _StockProps = 15
- Caption = "Auhor"
- BackColor = 12632256
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9.01
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- BevelOuter = 0
- Font3D = 3
- Alignment = 1
- End
- Begin Threed.SSPanel SSPanel5
- Height = 255
- Left = 120
- TabIndex = 13
- Top = 1680
- Width = 1215
- _Version = 65536
- _ExtentX = 2143
- _ExtentY = 450
- _StockProps = 15
- Caption = "Title"
- BackColor = 12632256
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "Verdana"
- Size = 9.01
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- BevelOuter = 0
- Font3D = 3
- Alignment = 1
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim DataArray(999, 3) As String
- Dim ArrayIndex As Integer
- Function BSearch(lower As Integer, upper As Integer, KeyField As String) As Integer
- Dim middle As Integer
- middle = Fix(lower + upper) / 2
- If List1.List(middle) = KeyField Then
- BSearch = middle
- Exit Function
- End If
- If lower >= upper Then
- BSearch = -1
- Exit Function
- End If
- If KeyField < List1.List(middle) Then
- upper = middle - 1
- Else
- lower = middle + 1
- End If
- BSearch = BSearch(lower, upper, KeyField)
- End Function
- Sub ClearFields()
- Text1.Text = ""
- Text2.Text = ""
- Text2.Locked = False
- Text3.Text = ""
- Text3.Locked = False
- Text4.Text = ""
- Text4.Locked = False
- DeleteButton.Visible = False
- AddButton.Visible = False
- OKButton.Visible = True
- CancelButton.Visible = True
- End Sub
- Sub ShowButtons()
- OKButton.Visible = False
- CancelButton.Visible = False
- AddButton.Visible = True
- DeleteButton.Visible = True
- Text2.Locked = True
- Text3.Locked = True
- Text4.Locked = True
- End Sub
- Private Sub AddButton_Click()
- ClearFields
- Text1.SetFocus
- End Sub
- Private Sub CancelButton_Click()
- ShowButtons
- List1_Click
- End Sub
- Private Sub DeleteButton_Click()
- If List1.ListIndex < 0 Then
- MsgBox "No item selected in the list"
- List1.RemoveItem List1.ListIndex
- End If
- End Sub
- Private Sub Form_Load()
- List1.Clear
- End Sub
- Private Sub List1_Click()
- If List1.ListIndex < 0 Then
- Text1.Text = ""
- Text2.Text = ""
- Text3.Text = ""
- Text4.Text = ""
- Exit Sub
- End If
- ItemIndex = List1.ItemData(List1.ListIndex)
- Text1.Text = List1.List(List1.ListIndex)
- Text2.Text = DataArray(ItemIndex, 1)
- Text3.Text = DataArray(ItemIndex, 2)
- Text4.Text = DataArray(ItemIndex, 3)
- End Sub
- Private Sub OKButton_Click()
- Key = Trim(Text1.Text)
- If Key = "" Then
- MsgBox "Key field must be non-mepty"
- Exit Sub
- End If
- position = BSearch(0, List1.ListCount - 1, Trim(Text1.Text))
- If position >= 0 Then
- reply = MsgBox("Key exists. Replace existing record?", vbYesNo)
- If reply = vbYes Then
- List1.RemoveItem position
- Else
- Text1.SetFocus
- Exit Sub
- End If
- End If
- ArrayIndex = ArrayIndex + 1
- List1.AddItem Key
- List1.ItemData(List1.NewIndex) = ArrayIndex
- DataArray(ArrayIndex, 1) = Text2.Text
- DataArray(ArrayIndex, 2) = Text3.Text
- DataArray(ArrayIndex, 3) = Text4.Text
- List1.ListIndex = List1.NewIndex
- ShowButtons
- End Sub
- Private Sub Text1_Change()
- If List1.ListCount = 0 Then Exit Sub
- position = BSearch(0, List1.ListCount - 1, (Text1.Text))
- If position >= 0 Then
- List1.ListIndex = position
- List1_Click
- Text2.Text = ""
- Text3.Text = ""
- Text4.Text = ""
- End If
- End Sub
-