Application developed with Visual Basic, Part 11. |
|
View
Code,
examine these changes - the new text Code to be
add is red.
Dim
WithEvents adoPrimaryRS As Recordset 'Type of AdRecordset1 Dim AdRecordset1 As Recordset ' Type of strdatasource Dim strdatasource As String Dim recordno As Long ---------------------------------------------------------------------------------------------------------------------- Private Sub cmddisplay_Click() (.................) End Sub --------------------------------------------------------------------------------------------------------------------- Private Sub cmddisplay_GotFocus() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_Load() 'Data Soure at current directory strdatasource = App.Path + "\res\KJV.mdb" 'Declare the adoPrimaryRS Dim db As Connection Set db = New Connection db.CursorLocation = adUseClient db.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" & strdatasource Set adoPrimaryRS = New Recordset adoPrimaryRS.Open "select Book,BookTitle,Chapter,TextData,Verse from BibleTable", db, adOpenStatic, adLockOptimistic 'Load icon - BookIco.ico Set Me.Icon = LoadPicture(App.Path & "\res\BookIco.ico") 'Load the picture - forum.gif Set Image1.Picture = LoadPicture(App.Path & "\res\forum.gif") 'Load the picture - Christus-th.gif Set Image2.Picture = LoadPicture(App.Path & "\res\Christus-th.gif") 'The datasource value of TextBox Set Me.txtFields.DataSource = adoPrimaryRS 'The database file Begin with the 2nd adoPrimaryRS.Move (Str(2)) ' Disable the CmdFirst and CmdPrevious CommandButtons with begin CmdFirst.Enabled = False CmdPrevious.Enabled = False 'Calcul the values of book, title, chapter and verse Call LabelAddress 'Tabstrip control For i = 0 To Frtb.Count - 1 With Frtb(i) .Move TabStrip1.ClientLeft, _ TabStrip1.ClientTop, _ TabStrip1.ClientWidth, _ TabStrip1.ClientHeight End With Next i ' Bring the first frTb control to the front. Frtb(0).ZOrder 0 'AdRecordset1 - Recordset object Dim db1 As Connection Set db1 = New Connection db1.CursorLocation = adUseClient db1.Open "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=" & strdatasource Set AdRecordset1 = New Recordset AdRecordset1.Open "select Book,BookTitle,Chapter,Verse from BibleTable", db1, adOpenStatic, adLockOptimistic '1- Cmbbook stores the orders of all books. '2- Cmbbookrecno stores the orders of the KJV records corresponding to the items of the Cmbbook. '3- Cmbtitle stores the titles of all books '4- Cmbtitlerecno stores the orders of the KJV records corresponding to the items of the Cmbtitle. With AdRecordset1 Cmbtitle.Clear Cmbbook.Clear .MoveFirst Do While Not .EOF 'where Chapter = 001 and Verse = 001 If Trim(.Fields(2).Value) = "001" And _ Trim(.Fields(3).Value) = "001" Then Cmbtitle.AddItem Trim(.Fields(1).Value) Cmbbook.AddItem Trim(.Fields(0).Value) recordno = Val(.AbsolutePosition) - 1 Cmbtitlerecno.AddItem Str(recordno) End If .MoveNext Loop End With 'The curent strings values Cmbtitle.Text = "Select" Cmbbook.Text = "Select" Cmbchapter.Text = "no select" Cmbverse.Text = "no select" End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_Resize() (.................) End Sub ---------------------------------------------------------------------------------------------------------------------- Private Sub Form_Unload(Cancel As Integer) (.................) End Sub ---------------------------------------------------------------------------------------------------------------------- Private Sub adoPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) '(.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdClose_Click() (.................) End Sub ---------------------------------------------------------------------------------------------------------------------- Private Sub cmdFirst_Click() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdLast_Click() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdNext_Click() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdPrevious_Click() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub SetButtons(bVal As Boolean) CmdClose.Visible = bVal CmdNext.Enabled = bVal CmdFirst.Enabled = bVal CmdLast.Enabled = bVal CmdPrevious.Enabled = bVal End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub List1_Click() (.................) End Sub ----------------------------------------------------------------------------------------------------------------------- 'Calcul the values of book, title, chapter and verse Private Sub LabelAddress() Titre.Caption = "Book: " + Trim(adoPrimaryRS.Fields.Item(0).Value) + ", Title: " + Trim(adoPrimaryRS.Fields.Item(1).Value) Chapter.Caption = "Chapter: " + Trim(adoPrimaryRS.Fields.Item(2).Value) + ", Verse: " + Trim(adoPrimaryRS.Fields.Item(4).Value) End Sub ---------------------------------------------------------------------------------------------------------------------- Private Sub TabStrip1_Click() (.................) End Sub ---------------------------------------------------------------------------------------------------------------------- Private Sub TxtWord_KeyPress(KeyAscii As Integer) (.................) End Sub |