嘿,我正在编写代码,以便您可以搜索特定文件夹中的单词,并在填写完文件夹路径后向您发送消息:“您已填写 C:\ Yes \ Test ”,我想有一个消息框来启用/禁用公告。我有这个,但它给了我错误:没有if的其他情况。我认为这是因为在代码中,如果实际结束,则说明如果结束则是2x。 (顺便说一下,在荷兰)
antwoord = MsgBox("Wilt u meldingen ontvangen van het invullen van folderpad & woord", vbExclamation + vbYesNo + vbDefaultButton2, "Meldingen")
If antwoord = vbYes Then
strPath = Application.InputBox("Folderpad. 'bijvoorbeeld: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
If Len(strPath) = 0 Then
MsgBox "Je hebt niks ingevuld", vbCritical
Else
MsgBox "Je hebt " & strPath & " " & "ingevoerd."
End If
strSearch = Application.InputBox("Woord", "WoordenZoeker door S3M")
If Len(strSearch) = 0 Then
MsgBox "Je hebt niks ingevuld", vbCritical
Else
MsgBox "Je hebt " & strSearch & " " & "ingevoerd."
If antwoord = vbNo Then
strPath = Application.InputBox("Folderpad. 'bijvoorbeeld: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
End If
strSearch = Application.InputBox("Woord", "WoordenZoeker door S3M")
End If```
答案 0 :(得分:0)
请尝试另一种方法。我不明白这些消息以及您实际想要执行的操作...此代码显示了第一个MsgBox,可以在Yes和No之间进行选择。如果按Yes,则将显示InputBox。如果您不输入任何内容,则MsgBox会说“某事”。然后代码继续下一行。如果您希望它在某些情况下停止,请告诉我们在哪里:
antwoord = MsgBox("Wilt u meldingen ontvangen van het invullen van folderpad & woord", _
vbExclamation + vbYesNo + vbDefaultButton2, "Meldingen")
If antwoord = vbYes Then
strPath = Application.InputBox("Folderpad. 'bijvoorbeeld: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
If Len(strPath) = 0 Then
MsgBox "Je hebt niks ingevuld", vbCritical
Else
MsgBox "you entered """ & strPath & """."
End If
Else
MsgBox "Je hebt " & strPath & " " & "ingevoerd."
Exit Sub 'The code stops here
End If
strSearch = Application.InputBox("Woord", "WoordenZoeker door S3M")
If Len(strSearch) = 0 Then
MsgBox "Je hebt niks ingevuld", vbCritical
Else
MsgBox "Je hebt " & strSearch & " " & "ingevoerd."
If antwoord = vbNo Then
strPath = Application.InputBox("Folderpad. 'bijvoorbeeld: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
End If
strSearch = Application.InputBox("Woord", "WoordenZoeker door S3M")
End If
答案 1 :(得分:0)
strPath = Application.InputBox("Directory. 'example: (C:\Users\ex\ample\WordSearcher)' ", "WordSearcher by S3M")
If Len(strPath) = 0 Then
MsgBox "You have not entered anything", vbCritical
Else
MsgBox "You entered" & " " & strPath
End If
strSearch = Application.InputBox("Word", "WordSearcher by S3M")
If Len(strSearch) = 0 Then
MsgBox "You have not entered anything", vbCritical
Else
MsgBox "You entered" & " " & strSearch
End If
答案 2 :(得分:0)
@FaneDuru这是翻译后的代码,我可以私下将整个代码发送给您吗?
anwser = MsgBox("Would you like to recieve notifications from the value of folderpath and word", _
vbExclamation + vbYesNo + vbDefaultButton2, "Notifications")
If anwser = vbYes Then
strPath = Application.InputBox("Folderpath. 'example: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
If Len(strPath) = 0 Then
MsgBox "You did not enter anything", vbCritical
Else
MsgBox "You have entered" & " " & strPath
End If
strSearch = Application.InputBox("Word", "WoordenZoeker door S3M")
If Len(strPath) = 0 Then
MsgBox "You have not entered anything", vbCritical
Else
MsgBox "You have entered" & " " & strSearch
Exit Sub 'The code stops here
End If
If anwser = vbNo Then
strPath = Application.InputBox("Folderpath. 'example: (C:\Users\voor\beeld\WoordenZoeker)' ", "WoordenZoeker door S3M")
End If
strSearch = Application.InputBox("Word", "WoordenZoeker door S3M")
End If