PDA

View Full Version : گذاشتن پسورد برای باز کردن tab page



bemilove
چهارشنبه 01 تیر 1390, 07:54 صبح
چگونه می توان برای باز کردن tab page پسورد گذاشت.?

bita_ziba77
چهارشنبه 01 تیر 1390, 08:19 صبح
با سلام
از كد زير مي توانيد در رخداد change مرتبط با Tab خود استفاده نماييد:


Private Sub TabCtl0_Change()

Dim strInput As String
Dim ctl As Control

' Hide controls on tab until correct password is entered
For Each ctl In Controls
If ctl.Tag = "*" Then
ctl.Visible = False
End If
Next ctl

' If tab page with Tab Index of 1 is selected
' show InputBox asking for password
If TabCtl0.Value = 1 Then
strInput = InputBox("Please enter a password to access this tab" & vbNewLine & vbNewLine & "PASSWORD = password", _
"Restricted Access")

' Check if value is entered into InputBox
' If no value entered display MsgBox
If strInput = "" Or strInput = Empty Then
MsgBox "No Input Provided", , "Required Data"
TabCtl0.Pages.Item(0).SetFocus
Exit Sub
End If

' Check InputBox value and if value is a match
' display tab and unhide hidden fields
If strInput = "password" Then

For Each ctl In Controls
If ctl.Tag = "*" Then
ctl.Visible = True
End If
Next ctl
' If incorrect password supplied return to tab (index 0)
Else
MsgBox ("Sorry, you do not have access to this information")
TabCtl0.Pages.Item(0).SetFocus

Exit Sub
End If
End If

End Sub

bemilove
پنج شنبه 02 تیر 1390, 01:07 صبح
ببخشيد، اگر بخواهيم براي ورود به tab page از يوزر وپسورد موجود در تيبل استفاده شود كد چگونه خواهد بود؟

bemilove
پنج شنبه 02 تیر 1390, 01:25 صبح
ممنون مي شوم اين نمونه را اصلاح كنيد(سوال را بالا پرسيدم)