Jump to content
• Sign Up

## Recommended Posts

I'm creating a simple quiz app but, if you get a question wrong, it doesn't subtract one from the score: Can anyone help? I've tried some different things but nothing works.

CODE

Global \$Score = 100

\$Start = Msgbox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")

If \$Start = 6 Then

_Questions ()

EndIf

Func _Questions()

\$Q1 = Inputbox("Quiz", "What is 2+2?")

\$Q2 = Inputbox("Quiz", "What is 2-2?")

\$Q3 = Inputbox("Quiz", "What is 2+2?")

If NOT \$Q1 = "4" Then

\$Score = \$Score = -1

EndIf

If NOT \$Q2 = "0" Then

\$Score = \$Score = -1

EndIf

If Not \$Q3 = "4" Then

\$Score = \$Score = -1

EndIf

Msgbox(64, "Quiz", "Your Done! Your score is: "&\$Score&"")

EndFunc

#### Share this post

##### Share on other sites

Try this...

```Global \$Score = 100

\$Start = MsgBox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")
If \$Start = 6 Then
_Questions()
EndIf

Func _Questions()
\$Q1 = InputBox("Quiz", "What is 2+2?")
\$Q2 = InputBox("Quiz", "What is 2-2?")
\$Q3 = InputBox("Quiz", "What is 2+2?")
If \$Q1 <> "4"  Then
\$Score -= 1
EndIf
If \$Q2 <> "0"  Then
\$Score -= 1
EndIf
If \$Q3 <> "4"  Then
\$Score -= 1
EndIf
MsgBox(64, "Quiz", "Your Done! Your score is: " & \$Score & "")
EndFunc   ;==>_Questions```

Thanks!

#### Share this post

##### Share on other sites

Heres a way to do it I added a part that calculates the % score

```\$Start = Msgbox(36, "Quiz", "Here, is a fun little quiz. Do you want to play?")
If \$Start = 6 Then
_Questions()
EndIf

Func _Questions()
\$QNum = 4; Number of questions
\$Score = \$QNum
\$Q1 = Inputbox("Quiz", "What is 2+2?")
\$Q2 = Inputbox("Quiz", "What is 2-2?")
\$Q3 = Inputbox("Quiz", "What is 2+2?")
\$Q4 = Inputbox("Quiz", "What is 3+3?")
If \$Q1 = "4" Then
Else
\$Score -= 1
EndIf
If \$Q2 = "0" Then
Else
\$Score -= 1
EndIf
If \$Q3 = "4" Then
Else
\$Score -= 1
EndIf
If \$Q4 = "6" Then
Else
\$Score -= 1
EndIf
\$Score /= \$QNum
\$Score *= 100
Msgbox(64, "Quiz", "Your Done! Your score is: "&\$Score&"%")
EndFunc```

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

• ### Recently Browsing   0 members

No registered users viewing this page.

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...