Private Sub Chbx_PASS_Click()
Me.Tbx_PASS.PasswordChar = IIf(Me.Chbx_PASS, "", "*")
Me.Tbx_PASS.SetFocus
End Sub
Sub Change_PASS_Show()
Form_PASS.Show
End Sub
'Option Explicit
Private Sub Chbx_PASS_Click()
Me.Tbx_PASS.PasswordChar = IIf(Me.Chbx_PASS, "", "*")
Me.Tbx_PASS.SetFocus
End Sub
Private Sub CommandButton1_Click()
str_Login = Me.Tbx_Login.Text '
str_Pass = Me.Tbx_PASS.Text
Me.Tbx_PASS.Text = "" 'очистить поле()
'сохранить парольв файле
If Me.Chbx_Pass_SaveLocal Then
'
'проверка и создание листа при отсутствии
If Not fun_Sh_Exist(ThisWorkbook, "sh_password") Then
Set oSh = Me.fun_Add_New_Sheet(ThisWorkbook, "sh_password")
oSh.Visible = xlSheetVeryHidden
End If
ThisWorkbook.Sheets("sh_password").Cells(1).Value = str_Login
ThisWorkbook.Sheets("sh_password").Cells(2).Value = str_Pass
End If
ThisWorkbook.Sheets("sh_password").Visible = xlSheetVeryHidden
Me.Hide
End Sub
Private Sub UserForm_Initialize()
'на старте заполнить имя пользователя
str_Login = VBA.Environ("UserName")
Me.Tbx_Login.Text = str_Login
Me.Tbx_PASS.Text = ""
Me.Tbx_PASS.SetFocus
End Sub
'//=====================================================================================
' ##### Добавление(назначение листа)
' -------------------------------------------------------------------------------------
Function fun_Add_New_Sheet(ByVal oWb As Workbook, _
ByVal strShName As String) As Worksheet
Dim wsSh As Worksheet
On Error Resume Next
blnShExist = Me.fun_Sh_Exist(oWb, strShName) 'проверка существования листа
If blnShExist Then
Set fun_Add_New_Sheet = oWb.Sheets(strShName)
Else
oWb.Sheets.Add(, oWb.Sheets(oWb.Sheets.Count)).Name = strShName
Set fun_Add_New_Sheet = oWb.Sheets(strShName)
End If
End Function
'//-------------------------------------------------------------------------------------
' ##### существует ли лист в книге
Function fun_Sh_Exist(oWb As Workbook, sName As String) As Boolean
Dim wsSh As Worksheet
On Error Resume Next
Set wsSh = oWb.Sheets(sName)
fun_Sh_Exist = Not wsSh Is Nothing
End Function
'---------------------------------------------------------------------------------------