⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 services.frm

📁 simple supermarket for beginners
💻 FRM
字号:
VERSION 5.00
Begin VB.Form services 
   BackColor       =   &H80000013&
   Caption         =   "Services Information"
   ClientHeight    =   6450
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11505
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6450
   ScaleWidth      =   11505
   WindowState     =   2  'Maximized
   Begin VB.CommandButton cmdnext 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Next"
      Height          =   495
      Left            =   6120
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   3240
      Width           =   1215
   End
   Begin VB.CommandButton cmdprevious 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Previous"
      Height          =   495
      Left            =   4680
      Style           =   1  'Graphical
      TabIndex        =   12
      Top             =   3240
      Width           =   1215
   End
   Begin VB.TextBox txtfrom 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   5280
      MaxLength       =   20
      TabIndex        =   11
      Top             =   1800
      Width           =   3135
   End
   Begin VB.Frame Frame1 
      Appearance      =   0  'Flat
      BackColor       =   &H80000013&
      Caption         =   " Operations "
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   3015
      Left            =   9240
      TabIndex        =   6
      Top             =   1440
      Width           =   1695
      Begin VB.CommandButton cmdexit 
         BackColor       =   &H00E0E0E0&
         Caption         =   "&Exit"
         Height          =   495
         Left            =   240
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   2160
         Width           =   1215
      End
      Begin VB.CommandButton cmddelete 
         BackColor       =   &H00E0E0E0&
         Caption         =   "&Delete"
         Height          =   495
         Left            =   240
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   1560
         Width           =   1215
      End
      Begin VB.CommandButton cmdupdate 
         BackColor       =   &H00E0E0E0&
         Caption         =   "&Update"
         Height          =   495
         Left            =   240
         Style           =   1  'Graphical
         TabIndex        =   8
         Top             =   960
         Width           =   1215
      End
      Begin VB.CommandButton cmdadd 
         BackColor       =   &H00E0E0E0&
         Caption         =   "&Add"
         Height          =   495
         Left            =   240
         Style           =   1  'Graphical
         TabIndex        =   7
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.TextBox txtdistance 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   5280
      MaxLength       =   9
      TabIndex        =   4
      Top             =   2520
      Width           =   3110
   End
   Begin VB.TextBox txtto 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   5280
      MaxLength       =   20
      TabIndex        =   2
      Top             =   2160
      Width           =   3110
   End
   Begin VB.Label Label4 
      BackColor       =   &H00FFC0C0&
      Caption         =   "Distance (Km)"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   300
      Left            =   3120
      TabIndex        =   5
      Top             =   2520
      Width           =   2175
   End
   Begin VB.Label Label3 
      BackColor       =   &H00FFC0C0&
      Caption         =   "Destination"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3120
      TabIndex        =   3
      Top             =   2160
      Width           =   2175
   End
   Begin VB.Label Label2 
      BackColor       =   &H00FFC0C0&
      Caption         =   "From"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3120
      TabIndex        =   1
      Top             =   1800
      Width           =   2175
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Services Information"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   495
      Left            =   3840
      TabIndex        =   0
      Top             =   360
      Width           =   4335
   End
End
Attribute VB_Name = "services"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim validated As Boolean
Dim vaccumated As Boolean
Dim cn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim add As Boolean

Private Sub cmdadd_Click()
add = True
clear
txtfrom.SetFocus
cmdupdate.Caption = "save"
End Sub

Private Sub cmdupdate_Click()
vaccumate
If vaccumated = False Then
    Exit Sub
End If
validate
If validated = False Then
    Exit Sub
End If
If add = True Then
    add = False
    RS.AddNew
    save
    RS.Update
    MsgBox "The Record has been Saved"
    RS.MoveLast
    Display
Else
    save
    RS.Update
    MsgBox "The Record has been Saved"
    Display
End If
cmdupdate.Caption = "update"
End Sub


Private Sub cmddelete_Click()
On Error Resume Next
RS.Delete
clear
MsgBox "The Record has been Deleted"
RS.MoveFirst
Display
If Err Then
MsgBox Err.Number + Err.Description
End If
End Sub

Private Sub cmdnext_Click()
On Error Resume Next
RS.MoveNext
Display
If RS.EOF = True Then
MsgBox "This is the last record"
RS.MovePrevious
End If
End Sub

Private Sub cmdprevious_Click()
On Error Resume Next
RS.MovePrevious
Display
If RS.BOF = True Then
MsgBox "This is the first record"
RS.MoveFirst
End If
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub Form_Load()
On Error Resume Next
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TRANSPORT.MDB;Persist Security Info=False"
RS.Open "select * from routes", cn, adOpenDynamic, adLockPessimistic
RS.MoveFirst
Display
If Err Then
MsgBox Err.Number + Err.Description
End If
End Sub

Public Sub Display()
txtfrom.Text = RS.Fields("From")
txtto.Text = RS.Fields("Destination")
txtdistance.Text = RS.Fields("Distance")
End Sub


Public Sub clear()
txtfrom.Text = ""
txtto.Text = ""
txtdistance.Text = ""
End Sub

Public Sub save()
    RS.Fields("From") = txtfrom.Text
    RS.Fields("Destination") = txtto.Text
    RS.Fields("Distance") = txtdistance.Text
End Sub

Public Sub validate()
validated = True

If IsNumeric(txtfrom.Text) Then
    Label2.ForeColor = vbRed
    MsgBox "Start point in letters"
    validated = False
    txtfrom.SetFocus
    SendKeys "{Home}+{End}"
    Exit Sub
ElseIf IsNumeric(txtto.Text) Then
    Label3.ForeColor = vbRed
    MsgBox "Destination in letters"
    validated = False
    txtto.SetFocus
    SendKeys "{Home}+{End}"
    Exit Sub
ElseIf Not IsNumeric(txtdistance.Text) Then
    Label4.ForeColor = vbRed
    MsgBox "Distance should be given in digits"
    validated = False
    txtdistance.SetFocus
    SendKeys "{Home}+{End}"
    Exit Sub
End If

End Sub

Public Sub vaccumate()

vaccumated = True

If txtfrom.Text = "" Then
    MsgBox "Start point required"
    vaccumated = False
    txtfrom.SetFocus
    Exit Sub
ElseIf txtto.Text = "" Then
    MsgBox "Destination required"
    vaccumated = False
    txtto.SetFocus
    Exit Sub
ElseIf txtdistance.Text = "" Then
    MsgBox "Distance between " & CStr(txtfrom.Text) & " and " & CStr(txtto.Text) & " is required", vbInformation, "Oops!"
    vaccumated = False
    txtto.SetFocus
    Exit Sub
End If

End Sub

Private Sub Image1_Click()
End

End Sub

Private Sub txtdistance_Change()
Label4.ForeColor = vbBlack
End Sub

Private Sub txtfrom_Change()
Label2.ForeColor = vbBlack
End Sub

Private Sub txtto_Change()
Label3.ForeColor = vbBlack
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -