Hour 6:

Application developed with Visual Basic, Part 15.


9th Step
, create the Biography.frm file.

The Biography.frm design.

Biography ...


  1. To create a Form - Biography ( Biography.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
    Biograhy
    Biography...
    2355
    0
    False
    True
    1 - Twip
    2 - Center Window
    0
    6255


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

  2. Add the files :
    From the ...\VB App\res folder copy the followihg files:
    • The (Bitmap Image) butterfly1.bmp file to the folder C:\Test\Test VB0\ res
    • The (Bitmap Image) butterfly2.bmp  file to the folder C:\Test\Test VB0\ res


  3. The Biography.frm View Object .

    Add the following controls from the Toolbox:
    Three PictureBox controls - picico, picicoOrg(1) and picicoOrg(2), five Label controls - Label1, Label2, Label3, Label4 and Label5,
    one Line control - Line1 and one CommandButton control - CmdDone.

    1. Add the PictureBox - picico, PictureBox Properties:
      A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.
      Name:
      Align:
      BackColor:
      Height:
      Left:
      Tabindex:
      ScaleMode:
      Top:
      Width:
      picico
      0 - None
      &H8000000E&
      585
      120
      0
      0 - User
      360
      1005


    2. Add the PictureBox - picicoOrg(1), PictureBox Properties:
      A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.
      Name:
      Align:
      BackColor:
      Height:
      Index:
      Left:
      Tabindex:
      ScaleMode:
      Top:
      Visible:
      Width:
      picicoOrg
      0 - None
      &H8000000E&
      585
      1
      0
      1
      1 - Twip
      1560
      False
      1000


    3. Add the PictureBox - picicoOrg(2), PictureBox Properties:
      A PictureBox control can display a graphic from a bitmap, icon, or metafile, as well as enhanced metafile, JPEG, or GIF files.
      Name:
      Align:
      BackColor:
      Height:
      Index:
      Left:
      Tabindex:
      ScaleMode:
      Top:
      Visible:
      Width:
      picicoOrg
      0 - None
      &H8000000E&
      585
      2
      1080
      2
      1 - Twip
      1560
      False
      1000


    4. Add the Timer- Timer1, Timer Properties:
      A Timer control can execute code at regular intervals by causing a Timer event to occur.

      Remarks
      The Timer control, invisible to the user, is useful for background processing.
      You can't set the Enabled property of a Timer for a multiple selection of controls other than Timer controls.

      Name:
      Interval:
      Left:
      Top:
      Timer1
      100
      2400
      1515


    5. Add the Label - Label1, 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:
      Label1
      0 - Left Justify
      Name: Chucri Simon Zouein.
      MS Sans Serif, Regular, 8
      255
      1200
      4
      120
      4215


    6. Add the Label - Label2, 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:
      Label2
      0 - Left Justify
      Birth day: 20-02-1959.
      MS Sans Serif, Regular, 8
      255
      1200
      5
      360
      4455


    7. Add the Label - Label3, 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:
      Label3
      0 - Left Justify
      Address: Sed El Baouchrie, Ferdaous Str., Korlokian Bld.
      MS Sans Serif, Regular, 8
      255
      1200
      6
      600
      4455


    8. Add the Label - Label4, 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:
      Label4
      0 - Left Justify
      Tel: 01691436.
      MS Sans Serif, Regular, 8
      255
      1200
      7
      840
      4215


    9. Add the Label - Label5, 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:
      Label5
      0 - Left Justify
      Signification: Engineer on Computing and Software Systems Science.
      MS Sans Serif, Regular, 8
      255
      1200
      8
      1080
      1815


    10. Add the Line - Line1, Line Properties:
      A Line control is a graphical control displayed as a horizontal, vertical, or diagonal line.
      Name:
      BorderWidth:
      X1:
      X2:
      Y1:
      Y2:
      Line1
      2
      1200
      6000
      1440
      1440


    11. 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
      4680
      0 - Standard
      3
      1560
      1095

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


  4. The Biography.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 load the icon - BookIco.ico and the Bitmap
      files - butterfly1.bmp and butterfly2.bmp.

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

    Dim IcoNmbr As Integer
    --------------------------------------------------------------------------------------------------------------------
    Private Sub CmdDone_Click()
    Unload Me
    End Sub
    Private Sub Form_Load()
    --------------------------------------------------------------------------------------------------------------------
    'Load the icon - BookIco.ico
    Set Me.Icon = LoadPicture(App.Path & "\res\BookIco.ico")

    'Load picture
    picico.Picture = LoadPicture(App.Path & "\res\butterfly1.bmp")
    picicoOrg(1).Picture = LoadPicture(App.Path & "\res\butterfly1.bmp")
    picicoOrg(2).Picture = LoadPicture(App.Path & "\res\butterfly2.bmp")

    IcoNmbr = 1
    Timer1.Interval = 100
    Timer1.Enabled = True
    End Sub
    --------------------------------------------------------------------------------------------------------------------
    Private Sub Form_Resize()
    picico.Left = (Line1.X1 - picico.Width) / 2
    picico.Top = picico.Height / 4
    End Sub
    --------------------------------------------------------------------------------------------------------------------
    Private Sub Timer1_Timer()
    picico.Picture = picicoOrg(IcoNmbr).Picture
    If IcoNmbr = 1 Then
    IcoNmbr = 2
    Else
    IcoNmbr = 1
    End If
    End Sub


  5. One possibility to load the Form - (Biography):
    From the Form - About, select the CommandButton - CmdCreated.

    1. Activate the CommandButton control - CmdCreate - ( member of the Form - About, About.frm).
      For this, add the following Text Code to the About.frm View Code:
      Private Sub CmdCreated_Click()
      Dim f As New Biography
      f.Show
      End Sub


  6. The About.Frm View Code - ( includes the text Code corresponding to load the Form - Biography).

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

    Private Sub CmdCreated_Click()
    Dim f As New Biography
    f.Show
    End Sub


    --------------------------------------------------------------------------------------------------------------------
    Private Sub CmdDone_Click()
    Unload Me
    End Sub

    --------------------------------------------------------------------------------------------------------------------
    Private Sub Form_Load()
    'Declare this 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 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 display the information about KJV.mdb file. The 1st record of KJV.mdb store this information
    With AdRecordset1
    .MoveFirst
    lbinfo.Caption = .Fields(0).Value
    End With


    End Sub


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

Previous
Home 15 Home
Next