Make your own free website on Tripod.com

 

CAPÍTULO 6

 

Para bajar los archivos del libro y de este capítulo (Base de datos como “Trains” y otros) ejecuta los siguientes pasos:

 

  1. http://www.course.com
  2. Student Downloads
  3. Search: 0-7895-4654-
  4. Download Student Files
  5. Data Files for Students (Windows)
  6.  4654-xd.exe  (188 KB)

 

 

frmInventory

 

Private Sub cmdRefresh_Click()

  'this is really only needed for multi user apps

  Data1.Refresh

End Sub

 

Private Sub cmdAdd_Click()

  Data1.Recordset.AddNew

End Sub

 

Private Sub cmdUpdate_Click()

  Data1.UpdateRecord

  Data1.Recordset.Bookmark = Data1.Recordset.LastModified

  Data1.Refresh

End Sub

 

Private Sub cmdDelete_Click()

  'this may produce an error if you delete the last

  'record or the only record in the recordset

  Data1.Recordset.Delete

  Data1.Recordset.MoveNext

End Sub

 

Private Sub cmdClose_Click()

  Unload Me

End Sub

 

Private Sub Form_Unload (Cancel  As Integer)

frmInventory.Show

End Sub

 

Private Sub Data1_Validate(Action As Integer, Save As Integer)

  'This is where you put validation code

  'This event gets called when the following actions occur

  Select Case Action

    Case vbDataActionMoveFirst

    Case vbDataActionMovePrevious

    Case vbDataActionMoveNext

    Case vbDataActionMoveLast

    Case vbDataActionAddNew

    Case vbDataActionUpdate

    Case vbDataActionDelete

    Case vbDataActionFind

    Case vbDataActionBookmark

    Case vbDataActionClose

  End Select

  Screen.MousePointer = vbHourglass

End Sub

 

Private Sub Data1_Reposition()

  Screen.MousePointer = vbDefault

  On Error Resume Next

  'This will display the current record position

  'for dynasets and snapshots

  Data1.Caption = "Record: " & (Data1.Recordset.AbsolutePosition + 1)

  'for the table object you must set the index property when

  'the recordset gets created and use the following line

  'Data1.Caption = "Record: " & (Data1.Recordset.RecordCount * (Data1.Recordset.PercentPosition * 0.01)) + 1

  DBCombo1.SelLength = 0

 

End Sub

 

 

Private Sub Data1_Error(DataErr As Integer, Response As Integer)

  'This is where you would put error handling code

  'If you want to ignore errors, comment out the next line

  'If you want to trap them, add code here to handle them

  MsgBox "Data error event hit err:" & Error$(DataErr)

  Response = 0  'throw away the error

End Sub

 

Private Sub mnuRailroads_Click()

frmRailroads.Left = frmInventory.Left

frmRailroads.Top = frmInventory.Top

frmRailroads.Show

frmInventory.Hide

 

End Sub

 

 

Private Sub mnuFind_Click()

stocknum = InputBox("Enter Stock Number", "Find")

If stocknum <> "" Then

    SearchString = "stockNumber = " & Val(stocknum)

    Data1.Recordset.FindFirst SearchString

    If Data1.Recordset.NoMatch = True Then

        MsgBox "No Matching Record", 0, "Find"

    End If

End If

End Sub

 

********         ********       *******

CAPÍTULO 7

 

frmMultQuiz

 

Private Sub cmdStart_Click()

Const upperbound = 9

Const lowerbound = 0

Randomize

For Index = 0 To 4

    lblMult1(Index).Caption = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    lblMult2(Index).Caption = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

    txtProduct(Index).Text = ""

    txtProduct(Index).BackColor = vbWhite

Next

txtProduct(0).SetFocus

StWatch1.Action = 3

StWatch1.Action = 1

 

   

   

End Sub

 

Private Sub cmdStop_Click()

StWatch1.Action = 2

For Index = 0 To 4

    If lblMult1(Index).Caption * lblMult2(Index).Caption = Val(txtProduct(Index).Text) Then

        txtProduct(Index).BackColor = vbGreen

    Else

        txtProduct(Index).BackColor = vbRed

    End If

Next

 

End Sub

 

Private Sub Form_Resize()

If frmMultQuiz.WindowState = 1 Then

    'do nothing

ElseIf frmMultQuiz.Width < 6780 Then

    frmMultQuiz.Width = 6780

Else

    Frame1.Left = (frmMultQuiz.ScaleWidth - Frame1.Width - 345 - 975) / 2

    cmdStart.Left = Frame1.Left + Frame1.Width + 345

    cmdStop.Left = Frame1.Left + Frame1.Width + 345

    StWatch1.Left = Frame1.Left + Frame1.Width + 345

End If

 

End Sub

 

Formato NotePad