สวัสดีครับอาจารย์ผมมีเรื่องมาปรึกษาต่อครับผมได้ทำ Userfom ขึ้นมาเพื่อใส่ password พอใส่ Password แล้วก็จะมี Userfom 2 ขึ้นมาเพื่อให้แก้ไขหรือเพิ่มข้อมูลโดยที่ผมจะซ่อน sheet data เเละผมลองเขียโค้ดต่อว่าเมื่อกรอกเสร็จแล้วให้บันทึกวันเวลาที่เข้าใช้ไปใน sheet username และมีผมที่เข้าไปดูข้อมูลได้คนเดียวในส่วนที่กล่ามาผมทำได้หมดแล้วแต่ไม่ทราบว่าถูกต้องหรือไม่ รบกวนอาจารย์ช่วยแนะนำให้ผมหน่อย ในส่วนที่ผมยังทำไม่ได้คือ
1.เมื่อกรอก passwordแล้วให้ขึ้น"******" ผมเข้าไปดูหลายตัวอย่างแล้วแต่ยังทำไม่ได้
2.คนที่จะเข้ามาแก้ข้อมูลและบันทึกได้มีหลายคนผมอยากให้มี password ของใครของมันเพื่อที่ผมจะเข้ามาดูว่าใครเข้ามาแก้ไขตอนไหนในส่วนนี้ผมลองหลายวิธีแล้วยังไม่ได้เลยครับ
Code: Select all
Private Sub CommandButton1_Click()
Dim username As String
Dim i As Integer
Dim irow As Long
Dim ws As Worksheet
username = TextBox1.Text
If username = "1234" Then
MsgBox "ยินดีต้อนรับเข้าสู่ระบบคุณภาพ", vbInformation
Unload Me 'unload this
UserForm2.Show
Else
i = i + 1
If i < 3 Then
MsgBox "Username ไม่ถูกต้อง", vbCritical
'now close the workbook
Else
Application.DisplayAlerts = False
Application.Quit
End If
End If
Set ws = Worksheets("username")
'find first empty row in username
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the username
ws.Cells(irow, 1).Value = Date
ws.Cells(irow, 2).Value = Time
ws.Cells(irow, 3).Value = Me.TextBox1.Value
End Sub
ส่วนอันนี้คือโค๊ตที่ผมลองแกะออกมา
รบกวนช่วยตรวจสอบและชี้แนะด้วยครับ
password 1234
ขอบคุณครับ
You do not have the required permissions to view the files attached to this post.