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

📄 form1.vb

📁 Visual Basic.net 实例入门
💻 VB
字号:
Public Class m_main
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents house As System.Windows.Forms.TextBox
    Friend WithEvents ydphone As System.Windows.Forms.TextBox
    Friend WithEvents zzphone As System.Windows.Forms.TextBox
    Friend WithEvents bgphone As System.Windows.Forms.TextBox
    Friend WithEvents office As System.Windows.Forms.TextBox
    Friend WithEvents email As System.Windows.Forms.TextBox
    Friend WithEvents yourname As System.Windows.Forms.TextBox
    Friend WithEvents m_add As System.Windows.Forms.Button
    Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
    Friend WithEvents OleDbCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents m_delete As System.Windows.Forms.Button
    Friend WithEvents m_list As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(m_main))
        Me.Label8 = New System.Windows.Forms.Label()
        Me.m_add = New System.Windows.Forms.Button()
        Me.yourname = New System.Windows.Forms.TextBox()
        Me.Label6 = New System.Windows.Forms.Label()
        Me.Label7 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.m_list = New System.Windows.Forms.Button()
        Me.house = New System.Windows.Forms.TextBox()
        Me.email = New System.Windows.Forms.TextBox()
        Me.zzphone = New System.Windows.Forms.TextBox()
        Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection()
        Me.bgphone = New System.Windows.Forms.TextBox()
        Me.m_delete = New System.Windows.Forms.Button()
        Me.OleDbCommand1 = New System.Data.OleDb.OleDbCommand()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label5 = New System.Windows.Forms.Label()
        Me.ydphone = New System.Windows.Forms.TextBox()
        Me.office = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(112, 176)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(170, 16)
        Me.Label8.TabIndex = 9
        Me.Label8.Text = "请点击按钮执行相应的操作。"
        '
        'm_add
        '
        Me.m_add.Location = New System.Drawing.Point(40, 208)
        Me.m_add.Name = "m_add"
        Me.m_add.TabIndex = 8
        Me.m_add.Text = "增加"
        '
        'yourname
        '
        Me.yourname.AcceptsTab = True
        Me.yourname.Location = New System.Drawing.Point(105, 20)
        Me.yourname.Name = "yourname"
        Me.yourname.Size = New System.Drawing.Size(80, 21)
        Me.yourname.TabIndex = 1
        Me.yourname.Text = ""
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(32, 119)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(72, 16)
        Me.Label6.TabIndex = 0
        Me.Label6.Text = "工作电位:"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(32, 151)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(72, 16)
        Me.Label7.TabIndex = 0
        Me.Label7.Text = "电子邮件:"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(31, 23)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(48, 16)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "姓名:"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(191, 23)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(80, 16)
        Me.Label2.TabIndex = 0
        Me.Label2.Text = "住宅电话:"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(31, 55)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(72, 16)
        Me.Label3.TabIndex = 0
        Me.Label3.Text = "办公电话:"
        '
        'm_list
        '
        Me.m_list.Location = New System.Drawing.Point(240, 208)
        Me.m_list.Name = "m_list"
        Me.m_list.TabIndex = 11
        Me.m_list.Text = "列出所有"
        '
        'house
        '
        Me.house.Location = New System.Drawing.Point(105, 80)
        Me.house.Name = "house"
        Me.house.Size = New System.Drawing.Size(240, 21)
        Me.house.TabIndex = 5
        Me.house.Text = ""
        '
        'email
        '
        Me.email.Location = New System.Drawing.Point(105, 144)
        Me.email.Name = "email"
        Me.email.Size = New System.Drawing.Size(240, 21)
        Me.email.TabIndex = 7
        Me.email.Text = ""
        '
        'zzphone
        '
        Me.zzphone.AcceptsTab = True
        Me.zzphone.Location = New System.Drawing.Point(263, 20)
        Me.zzphone.Name = "zzphone"
        Me.zzphone.Size = New System.Drawing.Size(80, 21)
        Me.zzphone.TabIndex = 2
        Me.zzphone.Text = ""
        '
        'OleDbConnection1
        '
        Me.OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=personal.m" & _
        "db;Mode=Share Deny None;Extended Properties="""";Jet OLEDB:System database="""";Jet " & _
        "OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;Je" & _
        "t OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Gl" & _
        "obal Bulk Transactions=1;Jet OLEDB:New Database Password="""";Jet OLEDB:Create Sys" & _
        "tem Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale " & _
        "on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=Fa" & _
        "lse"
        '
        'bgphone
        '
        Me.bgphone.Location = New System.Drawing.Point(105, 50)
        Me.bgphone.Name = "bgphone"
        Me.bgphone.Size = New System.Drawing.Size(80, 21)
        Me.bgphone.TabIndex = 3
        Me.bgphone.Text = ""
        '
        'm_delete
        '
        Me.m_delete.Location = New System.Drawing.Point(140, 208)
        Me.m_delete.Name = "m_delete"
        Me.m_delete.TabIndex = 10
        Me.m_delete.Text = "删除"
        '
        'OleDbCommand1
        '
        Me.OleDbCommand1.Connection = Me.OleDbConnection1
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(191, 55)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(72, 16)
        Me.Label4.TabIndex = 0
        Me.Label4.Text = "移动电话:"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(31, 87)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(72, 16)
        Me.Label5.TabIndex = 0
        Me.Label5.Text = "居住地点:"
        '
        'ydphone
        '
        Me.ydphone.Location = New System.Drawing.Point(263, 50)
        Me.ydphone.Name = "ydphone"
        Me.ydphone.Size = New System.Drawing.Size(80, 21)
        Me.ydphone.TabIndex = 4
        Me.ydphone.Text = ""
        '
        'office
        '
        Me.office.Location = New System.Drawing.Point(105, 112)
        Me.office.Name = "office"
        Me.office.Size = New System.Drawing.Size(240, 21)
        Me.office.TabIndex = 6
        Me.office.Text = ""
        '
        'm_main
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(392, 243)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.m_list, Me.m_delete, Me.Label8, Me.m_add, Me.email, Me.office, Me.house, Me.ydphone, Me.bgphone, Me.zzphone, Me.yourname, Me.Label7, Me.Label6, Me.Label5, Me.Label4, Me.Label3, Me.Label2, Me.Label1})
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "m_main"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "个人通信录"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub m_add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_add.Click
        If yourname.Text = "" Then '判断姓名字段是否为空
            Label8.Text = "对不起,姓名不能为空!"

        Else
            OleDbConnection1.Open() '打开连接
            OleDbCommand1.CommandText = "insert into txl(yourname,zzphone,bgphone,ydphone,house,office,email) values('" + yourname.Text + "','" + zzphone.Text + "','" + bgphone.Text + "','" + ydphone.Text + "','" + house.Text + "','" + office.Text + "','" + email.Text + "')"
            OleDbCommand1.ExecuteNonQuery() '向数据库中插入一行记录
            yourname.Text = ""
            zzphone.Text = ""
            bgphone.Text = ""
            ydphone.Text = ""
            house.Text = ""
            office.Text = ""
            email.Text = "" '将所有的编辑框内容清空
            Label8.Text = "已经成功地增加了一条记录。"
            OleDbConnection1.Close() '关闭连接
        End If

    End Sub

    Private Sub m_delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_delete.Click
        Dim deleteform As New personal.deletewindow()
        deleteform.Show()
    End Sub

    Private Sub m_list_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_list.Click
        Dim showform As New personal.showwindow()
        showform.Show()
    End Sub
End Class

⌨️ 快捷键说明

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