Option Strict Off Imports System.Data.SqlClient Public Class 個人帳號管理 Dim conn As New SqlConnection Dim cmd As New SqlCommand Dim dr As SqlDataReader Dim FFGG As Integer Dim DTP As String : Dim DDFF As String Private Sub Set_使用者資料() If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If SQL1 = "SELECT 姓名, 帳號, 密碼, 密碼日期 FROM 使用者 WHERE (姓名 = '" & gUserName & "')" cmd.Connection = conn : cmd.CommandText = SQL1 : dr = cmd.ExecuteReader If dr.Read() Then TextBox1.Text = dr("姓名").ToString TextBox2.Text = dr("帳號").ToString TextBox3.Text = dr("密碼").ToString TextBox4.Text = dr("密碼日期").ToString DDFF = dr("密碼").ToString End If conn.Close() : dr.Close() End Sub Private Sub Set_日期格式轉換() DTP = Format(Today(), "yyyy/MM/dd") End Sub Private Sub 個人帳號管理_Load(sender As Object, e As EventArgs) Handles MyBase.Load FormBorderStyle = FormBorderStyle.SizableToolWindow Set_使用者資料() TextBox1.Enabled = False : TextBox2.Enabled = False : TextBox4.Enabled = False : TextBox5.Enabled = False FFGG = DateDiff("d", TextBox4.Text, Format(Today(), "yyyy/MM/dd")) If CC(24) = False Then TextBox5.Text = "NA" Else TextBox5.Text = 密碼時限 - FFGG End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then MsgBox("輸入資料有誤") Else Set_日期格式轉換() If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If SQL1 = "UPDATE 使用者 SET 帳號 = '" & TextBox2.Text & "', 密碼 = '" & TextBox3.Text & "', 密碼日期 = '" & DTP & "' WHERE (姓名 = '" & TextBox1.Text & "')" cmd.CommandText = SQL1 : cmd.ExecuteNonQuery() : conn.Close() : conn.Close() MsgBox("修改完成") : Me.Close() End If Set_使用者資料() End Sub End Class