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

📄 frmmeals.frm

📁 菜谱管理系统。比较简单的VB代码
💻 FRM
字号:
VERSION 5.00
Object = "{FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0"; "DBLIST32.OCX"
Begin VB.Form frmMeals 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Meals"
   ClientHeight    =   9570
   ClientLeft      =   45
   ClientTop       =   735
   ClientWidth     =   9105
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   17340.51
   ScaleMode       =   0  'User
   ScaleWidth      =   10447.51
   Begin MSDBCtls.DBList dbList 
      Bindings        =   "frmMeals.frx":0000
      DataSource      =   "Data1"
      Height          =   1815
      Left            =   1200
      TabIndex        =   11
      Top             =   600
      Visible         =   0   'False
      Width           =   2895
      _ExtentX        =   5106
      _ExtentY        =   3201
      _Version        =   393216
      ListField       =   "Name"
   End
   Begin VB.TextBox txtNotes 
      DataField       =   "notes"
      DataSource      =   "Data1"
      Enabled         =   0   'False
      Height          =   1455
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   4
      Top             =   7200
      Width           =   8535
   End
   Begin VB.Data Data1 
      Caption         =   "Data1"
      Connect         =   "Access 2000;"
      DatabaseName    =   "C:\Cook\cook.mdb"
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   2760
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "Meals"
      Top             =   9000
      Width           =   3540
   End
   Begin VB.TextBox txtIngredients 
      DataField       =   "Ingredients"
      DataSource      =   "Data1"
      Enabled         =   0   'False
      Height          =   3375
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   2
      Top             =   960
      Width           =   8535
   End
   Begin VB.TextBox txtDirections 
      DataField       =   "Directions"
      DataSource      =   "Data1"
      Enabled         =   0   'False
      Height          =   2175
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   3
      Top             =   4680
      Width           =   8535
   End
   Begin VB.TextBox txtName 
      DataField       =   "Name"
      DataSource      =   "Data1"
      Enabled         =   0   'False
      Height          =   375
      Left            =   1200
      TabIndex        =   0
      Top             =   240
      Width           =   2895
   End
   Begin VB.Frame Frame3 
      Caption         =   "Recipe Notes"
      Height          =   1815
      Left            =   0
      TabIndex        =   10
      Top             =   6960
      Width           =   8775
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "ADD"
      Height          =   375
      Left            =   120
      TabIndex        =   5
      Top             =   8985
      Width           =   1095
   End
   Begin VB.CommandButton CmdEdit 
      Caption         =   "EDIT"
      Height          =   375
      Left            =   1440
      TabIndex        =   6
      Top             =   9000
      Width           =   1095
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "DELETE"
      Height          =   375
      Left            =   6480
      TabIndex        =   7
      Top             =   8985
      Width           =   1095
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "SAVE"
      Enabled         =   0   'False
      Height          =   375
      Left            =   7680
      TabIndex        =   8
      Top             =   8985
      Width           =   1095
   End
   Begin VB.TextBox txtSource 
      DataField       =   "Source"
      DataSource      =   "Data1"
      Enabled         =   0   'False
      Height          =   375
      Left            =   5880
      TabIndex        =   1
      Top             =   240
      Width           =   2895
   End
   Begin VB.CommandButton cmdList 
      Height          =   375
      Left            =   4080
      Picture         =   "frmMeals.frx":0014
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   240
      Width           =   375
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   8160
      Top             =   0
   End
   Begin VB.Frame Frame2 
      Caption         =   "Baking directions"
      Height          =   2535
      Left            =   0
      TabIndex        =   12
      Top             =   4440
      Width           =   8775
   End
   Begin VB.Frame Frame1 
      Caption         =   "Ingredients"
      Height          =   3735
      Left            =   0
      TabIndex        =   14
      Top             =   720
      Width           =   8775
   End
   Begin VB.CommandButton cmdEditDone 
      Caption         =   "DONE EDIT"
      Height          =   375
      Left            =   1440
      TabIndex        =   9
      Top             =   9000
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "Recipe Name"
      Height          =   195
      Left            =   0
      TabIndex        =   16
      Top             =   360
      Width           =   975
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Recipe Source"
      Height          =   195
      Left            =   4560
      TabIndex        =   15
      Top             =   360
      Width           =   1065
   End
   Begin VB.Menu mnuFile 
      Caption         =   "&File"
      Begin VB.Menu mnuFilePrint 
         Caption         =   "&Print "
         Shortcut        =   ^P
      End
      Begin VB.Menu mnuSep1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileClose 
         Caption         =   "&Close Form"
         Shortcut        =   ^C
      End
      Begin VB.Menu mnuSep2 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "E&xit"
         Shortcut        =   ^X
      End
   End
   Begin VB.Menu mnuRecipes 
      Caption         =   "&Recipes"
      Begin VB.Menu mnuRecipesMeals 
         Caption         =   "&Meals"
         Enabled         =   0   'False
         Shortcut        =   ^M
      End
      Begin VB.Menu mnuRecipesDeserts 
         Caption         =   "&Deserts"
         Shortcut        =   ^D
      End
   End
   Begin VB.Menu mnuWindow 
      Caption         =   "&Window"
      Begin VB.Menu mnuWindowTile 
         Caption         =   "&Tile"
      End
      Begin VB.Menu mnuWindowCascade 
         Caption         =   "&Cascade"
      End
   End
   Begin VB.Menu mnuAbout 
      Caption         =   "&About"
   End
End
Attribute VB_Name = "frmMeals"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Attribute VB_Name = "FrmMeals"
' Programed by James Letner 2003 (J-SOFT

Private Sub cmdAdd_Click()

' sets the enable propertys for the text boxes to true
' so a new record can be added to the cook.mdb

txtName.Enabled = True
txtSource.Enabled = True
txtNotes.Enabled = True
txtIngredients.Enabled = True
txtDirections.Enabled = True

' adds a new record to the cook.mdb
' also dsables the Add, Delete, Edit, cmdList buttons
' and enables the save record button

    cmdSave.Enabled = True
    cmdDelete.Enabled = False
    CmdEdit.Enabled = False
    cmdAdd.Enabled = False
    cmdList.Enabled = False
    Data1.Recordset.AddNew
    Data1.Refresh
    
'Keeps the user updated on the programs status

        fMainForm.sbStatusBar.Panels(1).Text = "Status: Adding Record To Database..."
        fMainForm.sbStatusBar.Refresh

End Sub

Private Sub cmdDelete_Click()

' Deletes a record for the cook.mdb

    Data1.Recordset.Delete
    Data1.Refresh

'Keeps the user updated on the programs status

        fMainForm.sbStatusBar.Panels(1).Text = "Status: Deleting Current Record..."
        fMainForm.sbStatusBar.Refresh
        Timer1.Enabled = True

End Sub

Private Sub cmdEdit_Click()

' sets the textbox enabled property yo true
' so the cooc.mdb can be edited

    txtName.Enabled = True
    txtSource.Enabled = True
    txtNotes.Enabled = True
    txtIngredients.Enabled = True
    txtDirections.Enabled = True

' allows the user to edit the current record in the cook.mdb
' also disables the Add, Delete, cmdList buttons
' and sets the visible property to false for the edit button
' and sets the cisible property for the Done Edit button to ture

        cmdSave.Enabled = False
        cmdDelete.Enabled = False
        CmdEdit.Visible = False
        cmdEditDone.Visible = True
        cmdAdd.Enabled = False
        cmdList.Enabled = False
        Data1.Recordset.Edit
        Data1.Refresh
        
'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Editing Curret Record..."
            fMainForm.sbStatusBar.Refresh

End Sub

Private Sub cmdEditDone_Click()

' Sets the text boxes propertys to false
' to keep the cook.mdb from being changed

    txtName.Enabled = False
    txtSource.Enabled = False
    txtNotes.Enabled = False
    txtIngredients.Enabled = False
    txtDirections.Enabled = False

' closes the edit mode for the cook.mdb
' also enables the Delete, Add, cmdList buttons
' and sets the visible property for Edit done to false
' and sets the visible property for the edit button to true

        cmdSave.Enabled = False
        cmdDelete.Enabled = True
        CmdEdit.Visible = True
        cmdEditDone.Visible = False
        cmdAdd.Enabled = True
        cmdList.Enabled = True
        Data1.Recordset.Edit
        Data1.Refresh

'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Saving Changes To Database..."
            fMainForm.sbStatusBar.Refresh
            Timer1.Enabled = True

End Sub

Private Sub cmdList_Click()

' Opens the dbList (quick Recipe find)
' Also refreshes the list so that its current

    dbList.Refresh
    dbList.Visible = True

End Sub

Private Sub cmdSave_Click()

' Sets the textbox propertys to false
' To keep the cook.mdb from being changed

    txtName.Enabled = False
    txtSource.Enabled = False
    txtNotes.Enabled = False
    txtIngredients.Enabled = False
    txtDirections.Enabled = False

' Saves a new record in the cook.mdb
' Also enables the Delete, Edit, Add, cmdList buttons
' And disables the save button

        cmdSave.Enabled = False
        cmdDelete.Enabled = True
        CmdEdit.Enabled = True
        cmdAdd.Enabled = True
        cmdList.Enabled = True
        Data1.Recordset.AddNew
        Data1.Refresh

'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Saving Record To Database..."
            fMainForm.sbStatusBar.Refresh
            Timer1.Enabled = True

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 = "Recipe 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

End Sub

Private Sub dbList_Click()

' This code updates the rest of the forms data
' fields when a record is selected
' From DBCNames

    Dim rs As Object
    Set rs = Me.Data1.Recordset.Clone
' NOTE:  [Name] = Record Field [dbList] = componet name
        rs.FindFirst "[Name] = '" & Me![dbList] & "'"
        Me.Data1.Recordset.Bookmark = rs.Bookmark
' NOTE: dbList = componet name
            dbList.Visible = False

End Sub

Private Sub Form_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Form_Load()

'timer to set the status bar for user

    Timer1.Enabled = True

End Sub

Private Sub Form_Unload(Cancel As Integer)

' Updates the status bar for the user

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Closing Database..."
    fMainForm.sbStatusBar.Refresh
    fMainForm.Timer1.Enabled = True

End Sub

Private Sub Frame1_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Frame2_Click()

' makes sure the dbList is hidden

    dbList.Visible = False
    
End Sub

Private Sub Label2_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub MnuAbout_Click()

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Loading Page..."
    fMainForm.sbStatusBar.Refresh

'Opens the about form and keeps it on top untill closed

        frmAbout.Show 1

End Sub

Private Sub MnuFileClose_Click()

' Closes the current form (frmDeserts)

    Unload Me

End Sub

Private Sub MnuFileExit_Click()

' Terminates the program and returns to the operating system

End

End Sub

Private Sub mnuFilePrint_Click()

'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Loading Print Form..."
    fMainForm.sbStatusBar.Refresh

' Opens the printing form wich starts printing data

        frmMPrint.Show

End Sub

Private Sub mnuRecipesDeserts_Click()

'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Opening Database..."
    fMainForm.sbStatusBar.Refresh

' Shows the frmDeserts for the user

        frmDeserts.Show

End Sub

Private Sub mnuWindowArrange_Click()


End Sub

Private Sub MnuWindowCascade_Click()

'Cascades the windows in the form

    fMainForm.Arrange vbCascade

End Sub

Private Sub MnuWindowTile_Click()

'tiles te windows in the main form

    fMainForm.Arrange vbTileVertical

End Sub

Private Sub Timer1_Timer()

'timer to set the status bar for user

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Running..."
    fMainForm.sbStatusBar.Refresh
    Timer1.Enabled = False
    Data1.Refresh
    
End Sub

Private Sub txtSource_Change()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

⌨️ 快捷键说明

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