Step 1:
Application developed with Visual Basic, Part 1. |
1st Step,
the beginning ...
|
2nd Step,
create the wizard Application .
Microsoft Visual Basic Application Wizard:
Programmatically, a Wizard is a form which contains a
variable number of frames (or "steps"), each of which
comprises a step to completing a Wizard’s task.
The Wizard steps ...:
First, run the Microsoft Visual Basic 6
Note : The Data Form Wizard dialog box appears ... |
Note: In the Database Name box displays 'C:\Test\Test VB0\res\KJV.mdb'. |
Note: The Data Form Wizard dialog box appears. |
Note: If the Source Code Control - (Add this project to SourceSafe) dialog box appears, click No. |
File | Description |
Book.frm | Form demonstrating database algorithms. |
Book.frx | Binary data file for the BOOK.FRM file. |
femMain.frm | The main form for the sample application. |
Module1.bas | Module containing shared code. |
TestVB0.vbp | Project file for this application. |
Note:
Book.frx - Binary data file save pictures in
cmdLast, cmdNext, cmdPrevious, cmdFirst buttons.
Some controls have properties that have binary data as
their values, such as the Picture property of picture box
and image controls or certain properties of custom
controls. Visual Basic saves all binary data for a form
in a binary data file separate from the form.
Visual Basic saves the binary data file in the same
directory as the form. The binary data file has the same
file name as the form, but it has an .frx filename
extension. Visual Basic reads the binary data file when
loading the form.
Dim WithEvents
adoPrimaryRS As Recordset Dim mbChangedByCode As Boolean Dim mvBookMark As Variant Dim mbEditFlag As Boolean Dim mbAddNewFlag As Boolean Dim mbDataChanged As Boolean 'Type of the strdatasource Dim strdatasource As String ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_Load() 'Value of the strdatasource at current directory strdatasource = App.Path + "\res\KJV.mdb" 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 Dim oText As TextBox 'Bind the text boxes to the data provider For Each oText In Me.txtFields Set oText.DataSource = adoPrimaryRS Next mbDataChanged = False End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_Resize() On Error Resume Next lblStatus.Width = Me.Width - 1500 cmdNext.Left = lblStatus.Width + 700 cmdLast.Left = cmdNext.Left + 340 End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If mbEditFlag Or mbAddNewFlag Then Exit Sub Select Case KeyCode Case vbKeyEscape cmdClose_Click Case vbKeyEnd cmdLast_Click Case vbKeyHome cmdFirst_Click Case vbKeyUp, vbKeyPageUp If Shift = vbCtrlMask Then cmdFirst_Click Else cmdPrevious_Click End If Case vbKeyDown, vbKeyPageDown If Shift = vbCtrlMask Then cmdLast_Click Else cmdNext_Click End If End Select End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub Form_Unload(Cancel As Integer) Screen.MousePointer = vbDefault 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) 'This will display the current record position for this recordset lblStatus.Caption = "Record: " & CStr(adoPrimaryRS.AbsolutePosition) End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub adoPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) 'This is where you put validation code 'This event gets called when the following actions occur Dim bCancel As Boolean Select Case adReason Case adRsnAddNew Case adRsnClose Case adRsnDelete Case adRsnFirstChange Case adRsnMove Case adRsnRequery Case adRsnResynch Case adRsnUndoAddNew Case adRsnUndoDelete Case adRsnUndoUpdate Case adRsnUpdate End Select If bCancel Then adStatus = adStatusCancel End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdClose_Click() Unload Me End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdFirst_Click() On Error GoTo GoFirstError adoPrimaryRS.MoveFirst mbDataChanged = False Exit Sub GoFirstError: MsgBox Err.Description End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdLast_Click() On Error GoTo GoLastError adoPrimaryRS.MoveLast mbDataChanged = False Exit Sub GoLastError: MsgBox Err.Description End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdNext_Click() On Error GoTo GoNextError If Not adoPrimaryRS.EOF Then adoPrimaryRS.MoveNext If adoPrimaryRS.EOF And adoPrimaryRS.RecordCount > 0 Then Beep 'moved off the end so go back adoPrimaryRS.MoveLast End If 'show the current record mbDataChanged = False Exit Sub GoNextError: MsgBox Err.Description End Sub ----------------------------------------------------------------------------------------------------------------------- Private Sub cmdPrevious_Click() On Error GoTo GoPrevError If Not adoPrimaryRS.BOF Then adoPrimaryRS.MovePrevious If adoPrimaryRS.BOF And adoPrimaryRS.RecordCount > 0 Then Beep 'moved off the end so go back adoPrimaryRS.MoveFirst End If 'show the current record mbDataChanged = False Exit Sub GoPrevError: MsgBox Err.Description 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 |