Всплывающее окно, требующее конкретного ответа

Я пытаюсь что-то настроить, чтобы немного повеселиться с моими коллегами, когда они нажимают на кнопку в Excel, что заставляет их отвечать на кучу математических задач, прежде чем разблокировать их систему. Если они ошибаются, я хочу, чтобы это звучало забавно.

Тем не менее, я пытаюсь найти лучший способ справиться с этим, и я не нахожу много онлайн, который делает то, что я ищу.

То, что у меня есть, не работает. Я продолжаю получать следующую ошибку: «Ожидаемая подфункция или свойство»

То, что у меня есть, довольно простое, но любая помощь будет принята с благодарностью.

Sub Button1_Click()

Dim ws As Worksheet
Dim a As String
Dim b As String
Dim c As String
Dim URL As String

'Lockout Functions
   'Cancel = True

'Check for Muted Sound, Unmute

'First Question
    a = Application.InputBox("What is 1+1?")
    If a = "2" Then 'continue
    Else goto a
    Application.Speech.Speak "Are you even trying?"
    MsgBox "Hi, you got that answer wrong"
    End If

'Second Question
    b = Application.InputBox("Finish this Sequence 1123_813__")
    If b = "1123581321" Then 'Continue
    Else goto b
    Application.Speech.Speak "It's the Fibonacci duh!"
    MsgBox "Hi, you got that answer wrong"
    End If  

'Third Question
    c = Application.InputBox("What are the next three numbers 1, 4, 9, 16, ?")
    If c = "1,4,9,16,25,36,49" Then 'continue
    Else goto c
    Application.Speech.Speak "Terrible!"
    MsgBox "Hi, you got that answer wrong"
    End If

'Unlock/Return Control
    'Cancel = False

End Sub
1
задан Pᴇʜ 19 March 2019 в 07:18
поделиться

1 ответ

Вам не нужны a, b и c в ELSE

Sub Button1_Click()

Dim ws As Worksheet
Dim a As String
Dim b As String
Dim c As String
Dim URL As String

'Lockout Functions
   'Cancel = True

'Check for Muted Sound, Unmute

'First Question
    a = Application.InputBox("What is 1+1?")
    If a = "2" Then 'continue
    Else
    Application.Speech.Speak "Are you even trying?"
    MsgBox "Hi, you got that answer wrong"
    End If

'Second Question
    b = Application.InputBox("Finish this Sequence 1123_813__")
    If b = "1123581321" Then 'Continue
    Else
    Application.Speech.Speak "It's the Fibonacci duh!"
    MsgBox "Hi, you got that answer wrong"
    End If  

'Third Question
    c = Application.InputBox("What are the next three numbers 1, 4, 9, 16, ?")
    If c = "1,4,9,16,25,36,49" Then 'continue
    Else
    Application.Speech.Speak "Terrible!"
    MsgBox "Hi, you got that answer wrong"
    End If

'Unlock/Return Control
    'Cancel = False

End Sub
0
ответ дан Lajos Arpad 19 March 2019 в 07:18
поделиться
Другие вопросы по тегам:

Похожие вопросы: