VBA中怎么将在文本框中输入的内容显示为星号,下面是一个高手写的加锁,解锁程序,输入密码怎么显示星号?
OptionExplicitSubBlattschutz_aufheben(wbkAsWorkbook)DimshtAsWorksheetDimstrKeyAsStrin...
Option Explicit
Sub Blattschutz_aufheben(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = InputBox("Please enter the password")
If strKey <> "qwe" Then
frmLock.Hide
Exit Sub
End If
wbk.Unprotect strKey
'On Error Resume Next
wbk.Sheets("defect").Visible = True
wbk.Sheets("Data").Visible = True
For Each sht In ActiveWorkbook.Sheets
sht.Unprotect strKey
Next
'On Error GoTo 0
End Sub
Sub Blattschutz_setzen(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = "qwe" 'InputBox("Bitte geben Sie das Passwort ein")
'On Error Resume Next
wbk.Sheets("defect").Visible = False
wbk.Sheets("Data").Visible = False
For Each sht In ActiveWorkbook.Sheets
'sht.Select
sht.EnableSelection = xlUnlockedCells
sht.Protect strKey
Next
wbk.Protect strKey, True, False
'On Error GoTo 0
End Sub
Sub Blattschutz_aufheben2(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = "qwe" 'InputBox("Please enter the password")
wbk.Unprotect strKey
'On Error Resume Next
wbk.Sheets("defect").Visible = True
wbk.Sheets("Data").Visible = True
For Each sht In ActiveWorkbook.Sheets
sht.Unprotect strKey
Next
'On Error GoTo 0
End Sub 展开
Sub Blattschutz_aufheben(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = InputBox("Please enter the password")
If strKey <> "qwe" Then
frmLock.Hide
Exit Sub
End If
wbk.Unprotect strKey
'On Error Resume Next
wbk.Sheets("defect").Visible = True
wbk.Sheets("Data").Visible = True
For Each sht In ActiveWorkbook.Sheets
sht.Unprotect strKey
Next
'On Error GoTo 0
End Sub
Sub Blattschutz_setzen(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = "qwe" 'InputBox("Bitte geben Sie das Passwort ein")
'On Error Resume Next
wbk.Sheets("defect").Visible = False
wbk.Sheets("Data").Visible = False
For Each sht In ActiveWorkbook.Sheets
'sht.Select
sht.EnableSelection = xlUnlockedCells
sht.Protect strKey
Next
wbk.Protect strKey, True, False
'On Error GoTo 0
End Sub
Sub Blattschutz_aufheben2(wbk As Workbook)
Dim sht As Worksheet
Dim strKey As String
strKey = "qwe" 'InputBox("Please enter the password")
wbk.Unprotect strKey
'On Error Resume Next
wbk.Sheets("defect").Visible = True
wbk.Sheets("Data").Visible = True
For Each sht In ActiveWorkbook.Sheets
sht.Unprotect strKey
Next
'On Error GoTo 0
End Sub 展开
2个回答
展开全部
这个代码是用的接收输入密码的窗口是 InputBox ,这个不能设置显示星号,即下面这句:
strKey = InputBox("Please enter the password")
要想用 星号 的话,必须使用 form 的窗体控件
strKey = InputBox("Please enter the password")
要想用 星号 的话,必须使用 form 的窗体控件
追问
能帮我编段代码吗?我自己不会用VBA,现在只是研究,连接还不会搞,谢谢!
追答
这个要用到form(窗体),就不单单是一段代码了
你可以到网上搜索下,excel登录系统,好多的范例
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询