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

📄 form2.frm

📁 vb得100个编程实例
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "在程序运行阶段建立数据库"
   ClientHeight    =   3435
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form2"
   ScaleHeight     =   3435
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "..."
      Height          =   375
      Left            =   2040
      TabIndex        =   10
      Top             =   120
      Width           =   615
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   2160
      Top             =   720
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox Text6 
      Height          =   390
      Left            =   3600
      TabIndex        =   6
      Text            =   "Name"
      Top             =   1920
      Width           =   855
   End
   Begin VB.TextBox Text5 
      Height          =   375
      Left            =   2640
      TabIndex        =   5
      Text            =   "Source"
      Top             =   1920
      Width           =   855
   End
   Begin VB.TextBox Text4 
      Height          =   375
      Left            =   3000
      TabIndex        =   4
      Text            =   "AllRecords"
      Top             =   960
      Width           =   1095
   End
   Begin VB.TextBox Text3 
      Height          =   375
      Left            =   840
      TabIndex        =   3
      Text            =   "Name"
      Top             =   1920
      Width           =   1095
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   840
      TabIndex        =   2
      Text            =   "Subclass"
      Top             =   960
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "创建"
      Height          =   495
      Left            =   1800
      TabIndex        =   1
      Top             =   2760
      Width           =   1455
   End
   Begin VB.TextBox Text1 
      ForeColor       =   &H8000000F&
      Height          =   375
      Left            =   3120
      Locked          =   -1  'True
      TabIndex        =   0
      Text            =   "文件名"
      Top             =   120
      Width           =   1215
   End
   Begin VB.Label Label3 
      Caption         =   "字段:"
      Height          =   375
      Left            =   120
      TabIndex        =   9
      Top             =   1920
      Width           =   495
   End
   Begin VB.Label Label2 
      Caption         =   "表:"
      Height          =   255
      Left            =   240
      TabIndex        =   8
      Top             =   1080
      Width           =   255
   End
   Begin VB.Label Label1 
      Caption         =   "数据库名称(保存在):"
      Height          =   255
      Left            =   360
      TabIndex        =   7
      Top             =   240
      Width           =   1815
   End
   Begin VB.Shape Shape2 
      Height          =   1695
      Left            =   2520
      Top             =   840
      Width           =   2055
   End
   Begin VB.Shape Shape1 
      Height          =   1695
      Left            =   720
      Top             =   840
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim FileName As String
Private Sub Command1_Click()
Dim PathName As String
PathName = App.Path

Dim MyTable As TableDef, MyField As Field
Dim MyDatabase As Database
   Set MyDatabase = CreateDatabase(FileName, dbLangGeneral)
   Set MyTable = MyDatabase.CreateTableDef(Text2.Text)
   Set MyField = MyTable.CreateField(Text3.Text, dbText, 50)
   MyTable.Fields.Append MyField
   MyDatabase.TableDefs.Append MyTable
   
   Set MyTable = MyDatabase.CreateTableDef(Text4.Text)
   Set MyField = MyTable.CreateField(Text5.Text, dbText, 50)
   MyTable.Fields.Append MyField
   Set MyField = MyTable.CreateField(Text6.Text, dbText, 50)
   MyTable.Fields.Append MyField
   MyDatabase.TableDefs.Append MyTable
   MsgBox "完成创建数据库 " + FileName
End Sub

Private Sub Command2_Click()

With CommonDialog1
    .CancelError = True
    .Filter = "数据库(*.mdb)|*.mdb"
     .Flags = cdlOFNHideReadOnly
    .ShowSave
    If Err.Number = cdlCancel Then
        Err.Clear
        Exit Sub
    End If

   FileName = .FileName
   
   Text1.Text = .FileTitle
End With

End Sub

⌨️ 快捷键说明

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