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

📄 frmsmtpsetting.vb

📁 <Visual Basic 数据库开发实例精粹(第二版)>一书首先介绍了Visual Basic(简称VB)开发的技巧和重点技术
💻 VB
字号:
Public Class frmSmtpSetting
  Inherits System.Windows.Forms.Form

  Protected m_szAccount As String

  Public Property Account() As String
    Get
      Return txtAccount.Text
    End Get
    Set(ByVal Value As String)
      m_szAccount = Value
    End Set
  End Property

  Public ReadOnly Property Pwd() As String
    Get
      Return txtPwd.Text
    End Get
  End Property

  Public ReadOnly Property SMTPServer() As String
    Get
      Return txtSmtpServer.Text
    End Get
  End Property

#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 窗体设计器修改此过程。
  '不要使用代码编辑器修改它。
  Public WithEvents picBG As System.Windows.Forms.Panel
  Public WithEvents _lblLogin_3 As System.Windows.Forms.Label
  Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
  Public WithEvents txtPwd As System.Windows.Forms.TextBox
  Public WithEvents txtSmtpServer As System.Windows.Forms.TextBox
  Public WithEvents labPwd As System.Windows.Forms.Label
  Public WithEvents labSMTPServer As System.Windows.Forms.Label
  Public WithEvents txtAccount As System.Windows.Forms.TextBox
  Public WithEvents labAccount As System.Windows.Forms.Label
  Public WithEvents btnOK As System.Windows.Forms.Button
  Public WithEvents btnCancel As System.Windows.Forms.Button
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmSmtpSetting))
    Me.txtPwd = New System.Windows.Forms.TextBox
    Me.txtSmtpServer = New System.Windows.Forms.TextBox
    Me.btnOK = New System.Windows.Forms.Button
    Me.btnCancel = New System.Windows.Forms.Button
    Me.labPwd = New System.Windows.Forms.Label
    Me.labSMTPServer = New System.Windows.Forms.Label
    Me.picBG = New System.Windows.Forms.Panel
    Me.PictureBox1 = New System.Windows.Forms.PictureBox
    Me._lblLogin_3 = New System.Windows.Forms.Label
    Me.txtAccount = New System.Windows.Forms.TextBox
    Me.labAccount = New System.Windows.Forms.Label
    Me.picBG.SuspendLayout()
    Me.SuspendLayout()
    '
    'txtPwd
    '
    Me.txtPwd.AcceptsReturn = True
    Me.txtPwd.AutoSize = False
    Me.txtPwd.BackColor = System.Drawing.SystemColors.Window
    Me.txtPwd.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtPwd.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtPwd.Location = New System.Drawing.Point(128, 103)
    Me.txtPwd.MaxLength = 0
    Me.txtPwd.Name = "txtPwd"
    Me.txtPwd.PasswordChar = Microsoft.VisualBasic.ChrW(42)
    Me.txtPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtPwd.Size = New System.Drawing.Size(210, 22)
    Me.txtPwd.TabIndex = 0
    Me.txtPwd.Text = "***"
    '
    'txtSmtpServer
    '
    Me.txtSmtpServer.AcceptsReturn = True
    Me.txtSmtpServer.AutoSize = False
    Me.txtSmtpServer.BackColor = System.Drawing.SystemColors.Window
    Me.txtSmtpServer.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtSmtpServer.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtSmtpServer.Location = New System.Drawing.Point(128, 133)
    Me.txtSmtpServer.MaxLength = 0
    Me.txtSmtpServer.Name = "txtSmtpServer"
    Me.txtSmtpServer.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtSmtpServer.Size = New System.Drawing.Size(210, 22)
    Me.txtSmtpServer.TabIndex = 1
    Me.txtSmtpServer.Text = "mail.trfsoft.com"
    '
    'btnOK
    '
    Me.btnOK.BackColor = System.Drawing.SystemColors.Control
    Me.btnOK.Cursor = System.Windows.Forms.Cursors.Default
    Me.btnOK.ForeColor = System.Drawing.SystemColors.ControlText
    Me.btnOK.Location = New System.Drawing.Point(162, 168)
    Me.btnOK.Name = "btnOK"
    Me.btnOK.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.btnOK.Size = New System.Drawing.Size(84, 25)
    Me.btnOK.TabIndex = 2
    Me.btnOK.Text = "确定(&O)"
    '
    'btnCancel
    '
    Me.btnCancel.BackColor = System.Drawing.SystemColors.Control
    Me.btnCancel.Cursor = System.Windows.Forms.Cursors.Default
    Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
    Me.btnCancel.ForeColor = System.Drawing.SystemColors.ControlText
    Me.btnCancel.Location = New System.Drawing.Point(262, 168)
    Me.btnCancel.Name = "btnCancel"
    Me.btnCancel.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.btnCancel.Size = New System.Drawing.Size(84, 25)
    Me.btnCancel.TabIndex = 3
    Me.btnCancel.Text = "取消(&E)"
    '
    'labPwd
    '
    Me.labPwd.AutoSize = True
    Me.labPwd.BackColor = System.Drawing.Color.Transparent
    Me.labPwd.Cursor = System.Windows.Forms.Cursors.Default
    Me.labPwd.ForeColor = System.Drawing.SystemColors.ControlText
    Me.labPwd.Location = New System.Drawing.Point(52, 106)
    Me.labPwd.Name = "labPwd"
    Me.labPwd.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.labPwd.Size = New System.Drawing.Size(29, 17)
    Me.labPwd.TabIndex = 18
    Me.labPwd.Text = "密码"
    '
    'labSMTPServer
    '
    Me.labSMTPServer.AutoSize = True
    Me.labSMTPServer.BackColor = System.Drawing.Color.Transparent
    Me.labSMTPServer.Cursor = System.Windows.Forms.Cursors.Default
    Me.labSMTPServer.ForeColor = System.Drawing.SystemColors.ControlText
    Me.labSMTPServer.Location = New System.Drawing.Point(52, 136)
    Me.labSMTPServer.Name = "labSMTPServer"
    Me.labSMTPServer.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.labSMTPServer.Size = New System.Drawing.Size(66, 17)
    Me.labSMTPServer.TabIndex = 17
    Me.labSMTPServer.Text = "SMTP服务器"
    '
    'picBG
    '
    Me.picBG.BackColor = System.Drawing.Color.FromArgb(CType(99, Byte), CType(117, Byte), CType(222, Byte))
    Me.picBG.Controls.Add(Me.PictureBox1)
    Me.picBG.Controls.Add(Me._lblLogin_3)
    Me.picBG.Cursor = System.Windows.Forms.Cursors.Default
    Me.picBG.Dock = System.Windows.Forms.DockStyle.Top
    Me.picBG.ForeColor = System.Drawing.SystemColors.WindowText
    Me.picBG.Location = New System.Drawing.Point(0, 0)
    Me.picBG.Name = "picBG"
    Me.picBG.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.picBG.Size = New System.Drawing.Size(389, 64)
    Me.picBG.TabIndex = 19
    '
    'PictureBox1
    '
    Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
    Me.PictureBox1.Location = New System.Drawing.Point(25, 16)
    Me.PictureBox1.Name = "PictureBox1"
    Me.PictureBox1.Size = New System.Drawing.Size(38, 29)
    Me.PictureBox1.TabIndex = 7
    Me.PictureBox1.TabStop = False
    '
    '_lblLogin_3
    '
    Me._lblLogin_3.AutoSize = True
    Me._lblLogin_3.BackColor = System.Drawing.Color.Transparent
    Me._lblLogin_3.Cursor = System.Windows.Forms.Cursors.Default
    Me._lblLogin_3.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
    Me._lblLogin_3.ForeColor = System.Drawing.Color.White
    Me._lblLogin_3.Location = New System.Drawing.Point(69, 19)
    Me._lblLogin_3.Name = "_lblLogin_3"
    Me._lblLogin_3.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me._lblLogin_3.Size = New System.Drawing.Size(154, 25)
    Me._lblLogin_3.TabIndex = 6
    Me._lblLogin_3.Text = "SMTP Server参数"
    '
    'txtAccount
    '
    Me.txtAccount.AcceptsReturn = True
    Me.txtAccount.AutoSize = False
    Me.txtAccount.BackColor = System.Drawing.SystemColors.Window
    Me.txtAccount.Cursor = System.Windows.Forms.Cursors.IBeam
    Me.txtAccount.ForeColor = System.Drawing.SystemColors.WindowText
    Me.txtAccount.Location = New System.Drawing.Point(128, 73)
    Me.txtAccount.MaxLength = 0
    Me.txtAccount.Name = "txtAccount"
    Me.txtAccount.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.txtAccount.Size = New System.Drawing.Size(210, 22)
    Me.txtAccount.TabIndex = 20
    Me.txtAccount.Text = "webmaster@trfsoft.com"
    '
    'labAccount
    '
    Me.labAccount.AutoSize = True
    Me.labAccount.BackColor = System.Drawing.Color.Transparent
    Me.labAccount.Cursor = System.Windows.Forms.Cursors.Default
    Me.labAccount.ForeColor = System.Drawing.SystemColors.ControlText
    Me.labAccount.Location = New System.Drawing.Point(52, 76)
    Me.labAccount.Name = "labAccount"
    Me.labAccount.RightToLeft = System.Windows.Forms.RightToLeft.No
    Me.labAccount.Size = New System.Drawing.Size(29, 17)
    Me.labAccount.TabIndex = 21
    Me.labAccount.Text = "帐号"
    '
    'frmSmtpSetting
    '
    Me.AcceptButton = Me.btnOK
    Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
    Me.CancelButton = Me.btnCancel
    Me.ClientSize = New System.Drawing.Size(389, 206)
    Me.Controls.Add(Me.txtAccount)
    Me.Controls.Add(Me.labAccount)
    Me.Controls.Add(Me.picBG)
    Me.Controls.Add(Me.txtPwd)
    Me.Controls.Add(Me.txtSmtpServer)
    Me.Controls.Add(Me.btnOK)
    Me.Controls.Add(Me.btnCancel)
    Me.Controls.Add(Me.labPwd)
    Me.Controls.Add(Me.labSMTPServer)
    Me.MaximizeBox = False
    Me.Name = "frmSmtpSetting"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
    Me.Text = "SMTP Server参数"
    Me.picBG.ResumeLayout(False)
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

    If txtAccount.Text = "" _
       Or txtPwd.Text = "" _
       Or txtSmtpServer.Text = "" Then
      MsgBox("请将信息填写完整", MsgBoxStyle.Critical + MsgBoxStyle.OKOnly)
      btnOK.DialogResult = DialogResult.None
      Exit Sub
    End If

    Me.DialogResult = DialogResult.OK
    Me.Close()

  End Sub

  Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
    Me.Close()
  End Sub

  Private Sub frmSmtpSetting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    txtAccount.Text = m_szAccount
    txtAccount.Focus()
  End Sub
End Class

⌨️ 快捷键说明

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