Hour 5:

Application developed with Visual Basic, Part 13.


8th Step, create the About.frm file.

The About.frm design.

About ...


  1. To create a Form - About (About.frm).
    From Project menu, choose Add Form, the Add Form dialog box appears, click the New tab, select the Form icon and then click Open.

    The design
    Form:
    Form1
    .
    .
    .
    .
    .
    .
    .
    .

    Modify the Form - Form1, Form properties:

    Items Old values New values
    Name:
    Caption:
    Height:
    Left:
    MaxButton:
    MinButton:
    ScaleMode:
    StartUpPosition:
    Top:
    Width:
    Form1
    Form1
    3600
    0
    True
    True
    1 - Twip
    0 - Windows Default
    0
    4800
    About
    About ...
    3105
    0
    False
    True
    1 - Twip
    2 - Center Window
    0
    5280


    From File menu, choose Save Project, the Save File As dialog box appears (File Name box = About) and then click Save.

  2. Add the file :
    • From the ...\VB App\res folder copy the (Bitmap Image) diam1.bmp file to the C:\Test\Test VB0\ res folder.
  3. The About.frm View Object:

    Add the following controls from the Toolbox:
    One Image control - Image1, two Label controls - lbKJVinfo and lbinfo, one Line control - Line1 and two CommandButton
    controls - CmdCreated and CmdDone.
    1. Add the Image - Image1, Image Properties:
      Use the Image control to display a graphic. An Image control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.
      Name:
      BorderStyle:
      Height:
      Left:
      Top:
      Width:
      Image1
      0 - None
      2175
      0
      0
      930

      Note:
      The Image1
      displays the file diam1.bmp. - (stored in the folder C:\Test\Test VB0\ res )


    2. Add the Label - lbKJVinfo, Label Properties:
      A Label control is a graphical control you can use to display text that a user can't change directly.
      Name:
      Alginment:
      Caption:
      Font:
      Height:
      Left:
      TabIndex:
      Top:
      Width:
      lbKJVinfo
      0 - Left Justify
      KJV database info:
      MS Sans Serif, Bold and italic, 8
      255
      1200
      0
      120
      1815


    3. Add the Label -lbinfo, Label Properties:
      A Label control is a graphical control you can use to display text that a user can't change directly.
      Name:
      Alginment:
      Caption:
      Height:
      Left:
      TabIndex:
      Top:
      Width:
      lbinfo
      0 - Left Justify
      Info ...
      1410
      1200
      1
      480
      3645

      Note:
      In the lbinfo, displays the data stored in the Textdata field of the 1st KJV database record.

    4. Add the Line - Line1, Line Properties:
      A Line control is a graphical control displayed as a horizontal, vertical, or diagonal line.
      Remarks
      :
      You can use a Line control at design time to draw lines on forms. At run time, you can use a Line control instead of, or in addition to, the Line method. Lines drawn with the Line control remain on the form even if the AutoRedraw property setting is False. Line controls can be displayed on forms, in picture boxes, and in frames. You can't use the Move method to move a Line control at run time, but you can move or resize it by altering its X1, X2, Y1, and Y2 properties. The effect of setting the BorderStyle property depends on the setting of the BorderWidth property. If BorderWidth isn't 1 and BorderStyle isn't 0 or 6, BorderStyle is set to 1.
      Name:
      BorderWidth:
      X1:
      X2:
      Y1:
      Y2:
      Line1
      2
      1080
      5030
      2040
      2040


    5. Add the CommandButton - CmdCreated, CommandButton Properties:
      Use a CommandButton control to begin, interrupt, or end a process. When chosen, a CommandButton appears pushed in and so is sometimes called a push button.
      Name:
      Caption:
      Height:
      Left:
      Style:
      TabIndex:
      Top:
      Width:
      CmdCreated
      Created by
      300
      1800
      0 - Standard
      2
      2280
      1095

      Note:
      To load the Form - Biography. (Click the
      CmdCreated button)

    6. Add the CommandButton - CmdDone, CommandButton Properties:
      Use a CommandButton control to begin, interrupt, or end a process. When chosen, a CommandButton appears pushed in and so is sometimes called a push button.
      Name:
      Caption:
      Height:
      Left:
      Style:
      TabIndex:
      Top:
      Width:
      CmdDone
      Done
      300
      3360
      0 - Standard
      3
      2280
      1095

      Note:
      To unload the current Form. (Click the CmdDone button)

  4. The About.frm View Code.

    Resume :

    • The procedure - (Sub CmdDone_Click) stores the step corresponding to unload the current Form.
    • The procedure - (Sub Form_Load) stores the step corresponding to display the Textdata field of the 1st KJV database record.

    View Code, examine these changes - the new text Code to be add is red.

    //To unload the current Form
    Private Sub CmdDone_Click()
    Unload Me
    End Sub

    --------------------------------------------------------------------------------------------------------------------
    Private Sub Form_Load()
    'Variable
    Dim strdatasource As String

    'Load the picture - diam1.bmp
    Set Image1.Picture = LoadPicture(App.Path & "\res\diam1.bmp")

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

    'Value of the strdatasource
    strdatasource = App.Path + "\res\KJV.mdb"

    'AdRecordset1 - recordset and db1 - connection
    Dim AdRecordset1 As Recordset
    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 TextData from BibleTable", db1, adOpenStatic, adLockOptimistic


    'lbinfo.Caption displays the information about the file KJV.mdb, stored in the 1st KJV database record.
    With AdRecordset1
    .MoveFirst
    lbinfo.Caption = .Fields(0).Value
    End With


    End Sub

    --------------------------------------------------------------------------------------------------------------------
    Private Sub Form_Resize()
    Image1.Left = (Line1.X1 - Image1.Width) / 2
    Image1.Top = (Me.Height - Image1.Height) / 4
    End Sub


  5. Two possibilities to load the Form - About:
    From the Book Form, select the CmdAbout CommandButton
    or
    from Info menu menu, click About.

    1. Activate the CommandButton control - CmdAbout - ( member of Book Form).
      For this, add the following text Code to the Book.frm View Code:
      Private Sub CmdAbout_Click()
      Dim f As New About
      f.Show
      End Sub


    2. Add a new item to the Info menu menu:
      • From the View menu, choose Project Explorer, at the Project window select the frmMain View Object.
        From the Tools menu, choose Menu Editor ... , the Menu Editor dialog box appears, add new item - About to this menu.

        The Properties values of the menu - Info menu, after modification:
        Item Menu Caption Name Other Properties
        1- Info menu
        2- Book
        3- (seperator bar)
        4- About
        5- (seperator bar)
        4- Exit
        Info Menu
        Book
        -
        About
        -
        Exit
        mnuFile
        mnuDataBook
        mnu1
        mnuAbout
        -
        mnuFileExit
        Enabled and Visible
        Enabled and Visible
        Enabled and Visible
        Enabled and Visible
        Enabled and Visible
        Enabled and Visible


      • The menu designs:

        Before modification   After modification.
         


      • Add the procedure - (Sub mnuAbout_Click) to the frmMain.frm View Code:

        Private Sub mnuAbout_Click()
        Dim f As New About
        f.Show
        End Sub
  6. The Book.Frm and frmMain.frm View Code. ( Next Page ------>)

Previous
Home 13 Home
Next