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

📄 picload.frm

📁 《VB6数据库开发指南》所有的例程的源码
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Chapter 5.4 Example - PictureBox"
   ClientHeight    =   4335
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   3795
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4335
   ScaleWidth      =   3795
   StartUpPosition =   3  'Windows Default
   Begin MSComDlg.CommonDialog cdlPicture 
      Left            =   1440
      Top             =   3660
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   327680
      Filter          =   "Bitmap files (*.bmp)|*.bmp|JPEG files (*.jpg, *.jpeg)|*.jpg;*.jpeg|GIF Files (*.gif)|*.gif|All Files (*.*)|*.*"
   End
   Begin VB.PictureBox picPicture 
      DataField       =   "Logo"
      DataSource      =   "dtaData"
      Height          =   2535
      Left            =   120
      ScaleHeight     =   2475
      ScaleWidth      =   3495
      TabIndex        =   2
      Top             =   540
      Width           =   3555
   End
   Begin VB.CommandButton cmdLoad 
      Caption         =   "&Load Picture"
      Height          =   525
      Left            =   120
      TabIndex        =   1
      Top             =   3690
      Width           =   1245
   End
   Begin VB.CommandButton cmdClose 
      Cancel          =   -1  'True
      Caption         =   "&Close"
      Height          =   525
      Left            =   2430
      TabIndex        =   0
      Top             =   3690
      Width           =   1245
   End
   Begin VB.Data dtaData 
      Caption         =   "Publishers"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  'DefaultCursor
      DefaultType     =   2  'UseODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   90
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "Publishers"
      Top             =   3210
      Width           =   3615
   End
   Begin VB.Label lblPublisherName 
      BorderStyle     =   1  'Fixed Single
      DataField       =   "Name"
      DataSource      =   "dtaData"
      Height          =   255
      Left            =   930
      TabIndex        =   4
      Top             =   150
      UseMnemonic     =   0   'False
      Width           =   2745
   End
   Begin VB.Label lblPublishers 
      Caption         =   "Publisher:"
      Height          =   195
      Left            =   120
      TabIndex        =   3
      Top             =   180
      Width           =   795
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Const BIBLIO_PATH = "D:\Program Files\Microsoft Visual Studio\VB6\Biblio.MDB"

Private Sub cmdClose_Click()
    End
End Sub

Private Sub cmdLoad_Click()
    On Error GoTo CancelLoad
        cdlPicture.ShowOpen
        On Error GoTo BadLoad
            picPicture = LoadPicture(cdlPicture.filename)
        On Error GoTo 0
    On Error GoTo 0
Exit Sub

CancelLoad:
    If Err.Number <> cdlCancel Then
        MsgBox Err.Description, vbExclamation
    Else
        Exit Sub
    End If

BadLoad:
    MsgBox Err.Description, vbExclamation
    Exit Sub
End Sub

Private Sub Form_Load()
    dtaData.DatabaseName = BIBLIO_PATH
    CheckForLogoField
End Sub

Private Sub CheckForLogoField()
    Dim dbfTemp As Database, tdfTemp As TableDef, fldTemp As Field
    Dim blnLogoFieldExists As Boolean
    
    On Error GoTo BadCheck
        Set dbfTemp = Workspaces(0).OpenDatabase(BIBLIO_PATH)
        For Each tdfTemp In dbfTemp.TableDefs
            If tdfTemp.Name = "Publishers" Then
                For Each fldTemp In tdfTemp.Fields
                    If fldTemp.Name = "Logo" Then
                        blnLogoFieldExists = True
                        Exit For
                    End If
                Next
                Exit For
            End If
        Next
        
        If blnLogoFieldExists = False Then
           If tdfTemp.Updatable Then
                Set fldTemp = New Field
                With fldTemp
                    .Name = "Logo"
                    .Type = dbLongBinary
                End With
                tdfTemp.Fields.Append fldTemp
            Else
                MsgBox "The database needs to be updated to Jet 3.0 format. " & _
                    "See How-To 5.7 for more information.", vbExclamation
            End If
        End If
    On Error GoTo 0
Exit Sub

BadCheck:
    MsgBox Err.Description, vbExclamation
    End
End Sub

⌨️ 快捷键说明

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