Ошибка возникает из-за того, что для каждого из ваших операторов If
требуется соответствующий терминатор End If
. Общий синтаксис оператора If
в VB: либо
If <test-expression> Then
<then-expression1>
...
<then-expressionN>
End If
, либо с аргументом Else
:
If <test-expression> Then
<then-expression1>
...
<then-expressionN>
Else
<else-expression1>
...
<else-expressionN>
End If
Следовательно, чтобы быть синтаксически правильным, ваш код должен становиться:
Answer1 = MsgBox("Will you be using any compensatory time?", vbYesNo + vbQuestion) = vbYes
If Answer1 = vbYes Then
CompTimeInfo = InputBox("You will need to calculate which days, and how many total hours of comp time you will use. Your comp time should be used up front, as in, if your orders begin on the 1st, you should use them on the next working day straight through. The next prompts will ask for this information. Please initial in the below box.", "AUS Date Initials")
End If
If Answer1 = vbNo Then
AUSDateWithoutComp = InputBox("Please initial here, indicating that you will not be using comp time. This signifies that your AUS start date aligns with your orders start date.", "AUS Start date - No Comp Time")
End if
Однако, обратите внимание, что ваше выражение then
не будет никогда не будет оценено, так как Answer1
будет содержать логическое значение (true / false) - результат сравнения значение, возвращаемое MsgBox
с vbYes
.
Поэтому я бы предложил написать ваш код как:
If MsgBox("Will you be using any compensatory time?", vbYesNo + vbQuestion) = vbYes Then
CompTimeInfo = InputBox("You will need to calculate which days, and how many total hours of comp time you will use. Your comp time should be used up front, as in, if your orders begin on the 1st, you should use them on the next working day straight through. The next prompts will ask for this information. Please initial in the below box.", "AUS Date Initials")
Else
AUSDateWithoutComp = InputBox("Please initial here, indicating that you will not be using comp time. This signifies that your AUS start date aligns with your orders start date.", "AUS Start date - No Comp Time")
End If