?? form4.vb
字號:
Public Class Form4
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 Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
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 txtUser As System.Windows.Forms.TextBox
Friend WithEvents txtPassWord As System.Windows.Forms.TextBox
Friend WithEvents txtPassWordOk As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form4))
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.txtUser = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.txtPassWord = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.txtPassWordOk = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 120)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(80, 24)
Me.Button1.TabIndex = 0
Me.Button1.Text = "確 定(&O)"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(184, 120)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(80, 24)
Me.Button2.TabIndex = 1
Me.Button2.Text = "取 消(&Q)"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(96, 16)
Me.Label1.TabIndex = 2
Me.Label1.Text = "請輸入用戶名"
'
'txtUser
'
Me.txtUser.Location = New System.Drawing.Point(112, 24)
Me.txtUser.Name = "txtUser"
Me.txtUser.Size = New System.Drawing.Size(176, 21)
Me.txtUser.TabIndex = 3
Me.txtUser.Text = "TextBox1"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(16, 56)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(104, 16)
Me.Label2.TabIndex = 4
Me.Label2.Text = "請輸入密碼"
'
'txtPassWord
'
Me.txtPassWord.Location = New System.Drawing.Point(112, 56)
Me.txtPassWord.Name = "txtPassWord"
Me.txtPassWord.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPassWord.Size = New System.Drawing.Size(176, 21)
Me.txtPassWord.TabIndex = 5
Me.txtPassWord.Text = "TextBox2"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(16, 88)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(96, 16)
Me.Label3.TabIndex = 6
Me.Label3.Text = "請確認密碼"
'
'txtPassWordOk
'
Me.txtPassWordOk.Location = New System.Drawing.Point(112, 88)
Me.txtPassWordOk.Name = "txtPassWordOk"
Me.txtPassWordOk.PasswordChar = Microsoft.VisualBasic.ChrW(42)
Me.txtPassWordOk.Size = New System.Drawing.Size(176, 21)
Me.txtPassWordOk.TabIndex = 7
Me.txtPassWordOk.Text = "TextBox3"
'
'Form4
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(296, 149)
Me.Controls.Add(Me.txtPassWordOk)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtPassWord)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.txtUser)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.ImeMode = System.Windows.Forms.ImeMode.On
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form4"
Me.Opacity = 0.9
Me.Text = "新建用戶"
Me.ResumeLayout(False)
End Sub
#End Region
'//VB.NET存在窗體的顯示和卸載和隱藏問題
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtUser.Text = ""
txtPassWord.Text = "" '//初始化
txtPassWordOk.Text = ""
End Sub
Private Sub txtUser_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUser.KeyPress
Dim KeyAscii As Short = Asc(e.KeyChar) '//回車設置焦點
If KeyAscii = 13 Then
txtPassWord.Focus()
txtPassWord.SelectionLength = txtPassWord.Text.Length
End If
If KeyAscii = 0 Then
e.Handled = True
End If
End Sub
Private Sub txtPassWord_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassWord.KeyPress
Dim KeyAscii As Short = Asc(e.KeyChar) '//回車設置焦點
If KeyAscii = 13 Then
txtPassWordOk.Focus()
txtPassWordOk.SelectionLength = txtPassWordOk.Text.Length
End If
If KeyAscii = 0 Then
e.Handled = True
End If
End Sub
Private Sub txtPassWordOk_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPassWordOk.TextChanged
End Sub
Private Sub txtPassWordOk_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtPassWordOk.KeyPress
Dim KeyAscii As Short = Asc(e.KeyChar) '//回車設置焦點
If KeyAscii = 13 Then
txtUser.Focus()
txtUser.SelectionLength = txtUser.Text.Length
End If
If KeyAscii = 0 Then
e.Handled = True
End If
End Sub
Public Sub printuserfile() '//將用戶信息存入文件
On Error Resume Next
Dim form As New Form3
Dim filename As String
form.ComboBox1.Items.Add(txtUser.Text)
filename = Application.StartupPath & "\save\" & "usersave.use"
FileOpen(1, filename, OpenMode.Append)
PrintLine(1, txtUser.Text & "," & txtPassWord.Text)
'//以行寫入文件
FileClose(1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim form As Form3
Dim i As Integer
'//核對工作
Try
If txtUser.Text = "" Then
MessageBox.Show("用戶名不能為空,請重新填寫用戶名", "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtUser.Focus()
txtUser.SelectionLength = txtUser.Text.Length
Exit Sub
End If
If txtPassWord.Text <> txtPassWordOk.Text Then
MessageBox.Show("密碼不相同,請核對密碼", "輸入錯誤", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtPassWord.Focus()
txtPassWord.SelectionLength = txtPassWord.Text.Length
Exit Sub
Else
printuserfile()
form.ListBox1.Items.Add(txtPassWord.Text)
'//為何一訪問其他窗體立即會退出本窗體
'form.ComboBox1.Items.Add(txtUser.Text)
MsgBox("該用戶以添加,你可以使用軟件的所有功能", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "操作成功")
Form4.ActiveForm.Close()
Exit Sub
End If
If txtPassWord.Text = "" Then
If MessageBox.Show("你沒有設置密碼,你的個人通訊資料將被別人瀏覽" & Chr(10) + Chr(13) & ",是否確認不設置密碼", "錯誤", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = DialogResult.Yes Then
txtPassWordOk.Focus()
'txtPassWordOk.SelectionLength = txtPassWordOk.Text.Length
Exit Sub
Else
printuserfile()
form.ListBox1.Items.Add(txtPassWord.Text)
'form.ComboBox1.Items.Add(txtUser.Text)
MsgBox("該用戶以添加,你可以使用軟件的所有功能", MsgBoxStyle.OKOnly + MsgBoxStyle.Exclamation, "操作成功")
Form4.ActiveForm.Close()
End If
End If
Catch
'//
Form4.ActiveForm.Close()
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form4.ActiveForm.Close()
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -