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

📄 frmse.vb

📁 基于vb.net的简单通信录
💻 VB
字号:
Public Class frmse
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    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

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Option1 As System.Windows.Forms.RadioButton
    Friend WithEvents Option2 As System.Windows.Forms.RadioButton
    Friend WithEvents Option3 As System.Windows.Forms.RadioButton
    Friend WithEvents File1 As MyOwnClass.MyOwnClass.FileOperator
    Friend WithEvents save As System.Windows.Forms.SaveFileDialog
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmse))
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Button2 = New System.Windows.Forms.Button
        Me.Option3 = New System.Windows.Forms.RadioButton
        Me.Option2 = New System.Windows.Forms.RadioButton
        Me.Option1 = New System.Windows.Forms.RadioButton
        Me.File1 = New MyOwnClass.MyOwnClass.FileOperator
        Me.save = New System.Windows.Forms.SaveFileDialog
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(112, 24)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(216, 21)
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(8, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(96, 16)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "请输入保存位置"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(336, 24)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "浏览...."
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Button2)
        Me.GroupBox1.Controls.Add(Me.Option3)
        Me.GroupBox1.Controls.Add(Me.Option2)
        Me.GroupBox1.Controls.Add(Me.Option1)
        Me.GroupBox1.Location = New System.Drawing.Point(8, 56)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(400, 100)
        Me.GroupBox1.TabIndex = 3
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "请选择保存类型"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(304, 64)
        Me.Button2.Name = "Button2"
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "确定"
        '
        'Option3
        '
        Me.Option3.Location = New System.Drawing.Point(24, 72)
        Me.Option3.Name = "Option3"
        Me.Option3.Size = New System.Drawing.Size(184, 24)
        Me.Option3.TabIndex = 2
        Me.Option3.Text = "Soap文档"
        '
        'Option2
        '
        Me.Option2.Location = New System.Drawing.Point(24, 48)
        Me.Option2.Name = "Option2"
        Me.Option2.Size = New System.Drawing.Size(184, 24)
        Me.Option2.TabIndex = 1
        Me.Option2.Text = "XML文档"
        '
        'Option1
        '
        Me.Option1.Location = New System.Drawing.Point(24, 24)
        Me.Option1.Name = "Option1"
        Me.Option1.Size = New System.Drawing.Size(184, 24)
        Me.Option1.TabIndex = 0
        Me.Option1.Text = "二进制文档"
        '
        'frmse
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.Color.FromArgb(CType(224, Byte), CType(224, Byte), CType(224, Byte))
        Me.ClientSize = New System.Drawing.Size(418, 166)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.TextBox1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmse"
        Me.Text = "frmse"
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub frmse_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = ""
        Option2.Checked = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox1.Text = "" Then
            MessageBox.Show("保存的位置不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
        Dim filename = TextBox1.Text
        Dim frm As New Form1
        If Option1.Checked = True Then
            If File1.GetFileFilter(filename) <> "bin" Then
                filename = filename & ".bin"
            End If
            frm.save(filename, "Binary")
        ElseIf Option2.Checked = True Then
            If File1.GetFileFilter(filename) <> "xml" Then
                filename = filename & ".xml"
            End If
            frm.save(filename, "XML")
        ElseIf Option3.Checked = True Then
            If File1.GetFileFilter(filename) <> "Soap" Then
                filename = filename & ".xml"
            End If
            frm.save(filename, "Soap")
        End If
        frm.ActiveForm.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With save
            .Title = "另存为"
            If Option1.Checked = True Then
                .FileName = "新建文件.bin"
                .Filter = "二进制文档(*.bin)|*.bin"
            End If
            If Option2.Checked = True Then
                .FileName = "新建文件.xml"
                .Filter = "XML文档(*.xml)|*.xml"
            End If
            If Option3.Checked = True Then
                .FileName = "新建文件.xml"
                .Filter = "Soap文档(*.xml)|*.xml"
            End If
            If .ShowDialog = DialogResult.Cancel Then Exit Sub
        End With
        TextBox1.Text = save.FileName
    End Sub
End Class

⌨️ 快捷键说明

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