Application developed with Visual Basic, Part 14.


Resume :

  • To load the About Form, the views Code corresponding ...
    1. The Book.frm 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 Cmbbook_Click()

      (.................)

      End Sub
      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Cmbchapter_Click()

      (.................)

      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Cmbtitle_Click()

      (.................)

      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Cmbverse_Click()
      (.................)
      End Sub
      ----------------------------------------------------------------------------------------------------------------------
      Private Sub CmdAbout_Click()
      Dim f As New About
      f.Show
      End Sub


      ----------------------------------------------------------------------------------------------------------------------
      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

      'The cmbbook stores the book number values and the cmbtitle stores the book title values
      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

      Cmbtitle.Text = "Select"
      Cmbbook.Text = "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)
      (.................)
      End Sub
      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Settitle(bVal As Boolean)
      (.................)
      End Sub
      ----------------------------------------------------------------------------------------------------------------------

      Private Sub Setbook(bVal As Boolean)
      (.................)
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Setchapter(bVal As Boolean)
      (.................)
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Setverse(bVal As Boolean)
      (.................)
      End Sub

      ----------------------------------------------------------------------------------------------------------------------

      Private Sub List1_Click()

      (.................)
      End Sub
      ----------------------------------------------------------------------------------------------------------------------
      'Calcul the values of book, title, chapter and verse
      Private Sub LabelAddress()
      (.................)
      End Sub

      -----------------------------------------------------------------------------------------------------------------------

      Private Sub TabStrip1_Click()
      (.................)
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub TxtWord_KeyPress(KeyAscii As Integer)
      (.................)
      End Sub


    2. The frmMain.frm View Code.

      Examine these changes - the new text Code to be add is red.


      Private Sub Form_Load()

      'New setting size of frmMain
      Me.Height = Screen.Height - 500
      Me.Width = Screen.Width
      Me.Top = 50
      Me.Left = 0

      'Load the icon - res/BookIco.ico file
      Set Me.Icon = LoadPicture(App.Path & "\res\BookIco.ico")

      'Load the picture and size - ingraphic1.gif file
      Set Image1.Picture = LoadPicture(App.Path & "\res\ingraphic1.gif")
      Image1.Left = (Me.Width - Image1.Width) / 2

      'Load the Caption value of Label and size - Lbword
      Lbword.Caption = "Learn how to write Visual Basic application ..."
      Lbword.Width = Me.Width - 235
      Lbword.Top = Image1.Top + Image1.Height + 2 * (sbStatusBar.Top - (Image1.Top + Image1.Height + Lbword.Height)) / 3
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub Form_Unload(Cancel As Integer)
      Dim i As Integer

      'close all sub forms
      For i = Forms.Count - 1 To 1 Step -1
      Unload Forms(i)
      Next

      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub mnuAbout_Click()
      Dim f As New About
      f.Show
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub mnuDataBook_Click()
      Dim f As New Book
      f.Show
      End Sub

      ----------------------------------------------------------------------------------------------------------------------
      Private Sub mnuFileExit_Click()
      'unload the form
      Unload Me

      End Sub


    3. To save this application; From File menu, choose and click Save Project.
    4. To run it; From Run menu, choose and click Start.

    Previous
    Home 14 Home
    Next