標題:
[發問]
無法產生inputbox
[打印本頁]
作者:
henry860608
時間:
2020-8-6 00:19
標題:
無法產生inputbox
本帖最後由 henry860608 於 2020-8-6 00:32 編輯
1.檔案中有4個工作表,分別為工作表1~4,工作表3有程式碼(使用者須輸入密碼),但是從工作表1切換過去到工作表3,程式碼先檢查權限,不足則輸入密碼。但是密碼的視窗無法產生,而會使檔案當掉,請問有方法解決嗎?
2.附件與代碼如下。
Public Function InputBoxEr(Sht As Integer, iRow As Integer, Optional AddStr) As String
Dim Prompt As String, Title As String, Default As String, HelpFile As String, Context As String, Hack As String, tmp As String
Dim Xpos As Double, Ypos As Double
Dim i As Integer, Count As Integer, RoleSet As Integer, LmtCnt As Integer, Delay As Integer, min As Integer, sec As Integer
Dim StartRecTime As Date, EndtRecTime As Date, StartTime As Date, EndTime As Date
With Sheets(Sht)
Prompt = .Cells(iRow, 1)
Title = .Cells(iRow, 2)
Default = .Cells(iRow, 3)
Xpos = .Cells(iRow, 4)
Ypos = .Cells(iRow, 5)
HelpFile = .Cells(iRow, 6)
Context = .Cells(iRow, 7)
Hack = .Cells(iRow, 8)
RoleSet = .Cells(iRow, 10)
LmtCnt = .Cells(iRow, 11)
Delay = .Cells(iRow, 12)
StartRecTime = .Cells(iRow, 13)
EndtRecTime = .Cells(iRow, 14)
StartTime = .Cells(iRow, 15)
EndTime = .Cells(iRow, 16)
Count = .Cells(iRow, 8)
If RoleSet >= 0 Then
Else
MsgBox "錯誤!": Exit Function
End If
If (LmtCnt > 0 And Delay > 0) Or (LmtCnt = 0 And Delay = 0) Then
Else
MsgBox "錯誤!": Exit Function
End If
If RoleSet > Sheets(2).Cells(4, 3) Then
MsgBox "權限不足": Exit Function
ElseIf EndtRecTime > Now() Then
min = Int((Now() - EndtRecTime) / 24 / 60): sec = Int((Now() - EndtRecTime) / 24 / 60 / 60)
MsgBox "已在 " & Delay & " 分鐘內嘗試操作 " & LmtCnt & " 次,請於" & EndtRecTime & "後嘗試,剩下" & min & "分" & sec & "秒": Exit Function
ElseIf StartTime > Now() And Not (IsEmpty(StartTime)) Then
MsgBox "系統目前尚未開放!": Exit Function
ElseIf EndTime < Now() And Not (IsEmpty(EndTime)) Then
MsgBox "系統目前已關閉!": Exit Function
Else
.Cells(iRow, 13) = Now(): .Cells(iRow, 14) = .Cells(iRow, 13) + LmtCnt / 24 / 60
End If
If Count = 0 And EndtRecTime <= Now() Then
.Cells(iRow, 17) = 1
Else
.Cells(iRow, 17) = .Cells(iRow, 17) + 1
End If
If IsEmpty(Hack) Then
'If Xpos = 0 Or Ypos = 0 Then
' InputBoxEr = InputBox(Prompt, Title, Default, , , HelpFile, Context)
'Else
InputBoxEr = InputBox(Prompt, Title, Default, Xpos, Ypos, HelpFile, Context)
'End If
Else
tmp = Sheets(2).Cells(5, 3): Sheets(2).Cells(5, 3) = Hack
'If Xpos = 0 Or Ypos = 0 Then
' InputBoxEr = InputBoxDK(Prompt, Title, Default, , , HelpFile, Context)
'Else
InputBoxEr = InputBoxDK(Prompt, Title, Default, Xpos, Ypos, HelpFile, Context)
'End If
End If
End With
Sheets(2).Cells(5, 3) = tmp
End Function
複製代碼
[attach]32376[/attach]
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)