Всплывающее окно, требующее конкретного ответа - PullRequest
1 голос
/ 18 марта 2019

Я пытаюсь что-то настроить, чтобы немного повеселиться с моими коллегами, когда при нажатии на кнопку в 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 Ответ

1 голос
/ 18 марта 2019

Вам не нужны 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...