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

📄 form3.vb

📁 基于vb.net的简单通信录
💻 VB
字号:
Imports System.IO
Public Class Form3
    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 ComboBox1 As System.Windows.Forms.ComboBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents btnNew As System.Windows.Forms.Button
    Friend WithEvents txtpass As System.Windows.Forms.TextBox
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form3))
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.txtpass = New System.Windows.Forms.TextBox
        Me.btnNew = New System.Windows.Forms.Button
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.SuspendLayout()
        '
        'ComboBox1
        '
        Me.ComboBox1.Location = New System.Drawing.Point(152, 200)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(192, 20)
        Me.ComboBox1.TabIndex = 0
        Me.ComboBox1.Text = "ComboBox1"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 200)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(112, 16)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "请选择登录用户"
        '
        'Button1
        '
        Me.Button1.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Button1.Location = New System.Drawing.Point(24, 264)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(80, 24)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "确   定(&O)"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(128, 264)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(88, 24)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "退   出(&E)"
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(360, 192)
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.PictureBox1.TabIndex = 4
        Me.PictureBox1.TabStop = False
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 232)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(104, 16)
        Me.Label2.TabIndex = 5
        Me.Label2.Text = "请输入密码"
        '
        'txtpass
        '
        Me.txtpass.Location = New System.Drawing.Point(152, 232)
        Me.txtpass.Name = "txtpass"
        Me.txtpass.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.txtpass.Size = New System.Drawing.Size(192, 21)
        Me.txtpass.TabIndex = 6
        Me.txtpass.Text = ""
        '
        'btnNew
        '
        Me.btnNew.Location = New System.Drawing.Point(248, 264)
        Me.btnNew.Name = "btnNew"
        Me.btnNew.Size = New System.Drawing.Size(88, 24)
        Me.btnNew.TabIndex = 7
        Me.btnNew.Text = "新建用户(&N)"
        '
        'ListBox1
        '
        Me.ListBox1.ItemHeight = 12
        Me.ListBox1.Location = New System.Drawing.Point(208, 296)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(88, 112)
        Me.ListBox1.TabIndex = 8
        Me.ListBox1.Visible = False
        '
        'Form3
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(354, 296)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.btnNew)
        Me.Controls.Add(Me.txtpass)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.ComboBox1)
        Me.Controls.Add(Me.PictureBox1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "Form3"
        Me.Opacity = 0.9
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "登录红叶通讯录"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim _passwordlist As ArrayList
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim form As New Form3
        'form.Close()
        Form3.ActiveForm.Close()
        End
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Dim form As New Form1
        'form.ShowDialog()
        Dim form As New Form3
        Dim _form As New Form1
        If txtpass.Text = strpassword Then
            form.ActiveForm.Close()
            ' Form.Close()
            'Form3.ActiveForm.Close()
            isok = True
            Exit Sub
        Else
            MessageBox.Show("密码不正确,请重新输入密码", "错误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtpass.Focus()
            txtpass.SelectAll()
            form.Focus()
            isok = False
            '_form.Hide()
        End If
    End Sub

   
    Public Structure passwordlist
        Public password As String
    End Structure



    Public Sub adduser(ByVal username As String, ByVal pass_word As String)
        ' Dim _password As passwordlist
        '_password.password = pass_word
        '_password.password()
        'ComboBox1.Items.Clear()
        ComboBox1.Items.Add(username)
        ListBox1.Items.Add(pass_word)
        'Return _password
    End Sub
    Public Sub _add()
        Dim username As String
        Dim userpassword As String
        Dim filename As String = Application.StartupPath & "\save\" & "usersave.use"
        ComboBox1.Items.Clear()
        FileOpen(1, filename, OpenMode.Input)
        Do While Not EOF(1)
            Input(1, username)
            Input(1, userpassword)

            'ComboBox1.Items.Add(username)
            'ListBox1.Items.Add(userpassword)
            adduser(username, userpassword)
        Loop
        ComboBox1.Text = ComboBox1.Items.Item(0)    '//添加到列表框
        FileClose(1)
    End Sub
    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim filename As String = Application.StartupPath & "\save\" & "usersave.use"
        Dim fileinfo As New FileInfo(filename)
        Dim username As String
        Dim userpassword As String
        'Dim filename As String = Application.StartupPath & "\" & "usersave.use"
        If fileinfo.Exists = False Then
            ComboBox1.Text = "Administrator"
        Else
            _add()
            'FileOpen(1, filename, OpenMode.Input)
            'Do While Not EOF(1)
            'Input(1, username)
            'Input(1, userpassword)
            'adduser(username, userpassword)
            'ComboBox1.Items.Clear()
            ' ComboBox1.Items.Add(username)
            '_passwordlist.Add(userpassword)
            'Loop
            'FileClose(1)
        End If
        intindex = 0
        '  Form3.ActiveForm.Close()
    End Sub

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        Dim form As New Form4
        form.ShowDialog()
    End Sub
    Dim intindex As Integer
    Dim strpassword As String
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        intindex = ComboBox1.SelectedIndex
        strpassword = ListBox1.Items.Item(intindex)
    End Sub


    Private Sub txtpass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpass.TextChanged

    End Sub

    Private Sub txtpass_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpass.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If KeyAscii = 13 Then
            Button1_Click(Nothing, Nothing)
        End If
        If KeyAscii = 0 Then
            e.Handled = True
        End If
    End Sub
End Class

⌨️ 快捷键说明

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