If returnvalue = yes then help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

If returnvalue = yes then help

homedog44homedog44 Posts: 1Member
First off, im new to VBA and need help with the returnvalue part. When i run this no matter if i click yes or no, it shows the yes dialog, and
wont + 1 to cells (15,6)

Not necessarily looking for a direct answer, examples would be great, and please tell me if i have the dim right and numRight right also. Thanks in advance

[code]Private Sub cmdGo_Click()


Dim numRight As Integer 'I think this is right
numRight = 0

'Clears all cells when button is pushed
Cells(4, 2) = ("")
Cells(5, 3) = ("")
Cells(6, 2) = ("")
Cells(7, 3) = ("")
Cells(8, 2) = ("")
Cells(9, 3) = ("")
Cells(10, 2) = ("")
Cells(11, 3) = ("")
Cells(12, 2) = ("")
Cells(13, 3) = ("")
Cells(15, 6) = 0

'Questions and Answers
'We add MsgBox to pause the script

Cells(4, 2) = ("1. What programming language is used with Excel?") 'Question 1
MsgBox "What programming language is used with Excel?", , "Question 1"

Cells(5, 3) = ("VBA or Visual Basic for Applications") 'Answer 1
MsgBox "VBA or Visual Basic for Applications", , "Answer"
MsgBox "Did you get it right?", vbYesNo, "Did you get it right?"
If MsgBoxreturnvalue = yes Then
MsgBox "Congratulations", , "Good Job"
Cells(15, 6) = Val(numRight) + 1
Else
MsgBox "Better luck next time", , "Sorry"
End If

'_____________________________________________________________________________________________________________________

Cells(6, 2) = ("What key sequence activates the VBA Editor?") 'Question 2
MsgBox "What key sequence activates the VBA Editor?", , "Question 2"

Cells(7, 3) = ("Alt-F11") 'Answer 2
MsgBox "Alt-F11", , "Answer"
MsgBox "Did you get it right?", vbYesNo, "Did you get it right?"
If returnvalue = yes Then
MsgBox "Congratulations", , "Good Job"
Cells(15, 6) = Val(numRight) + 1
Else
MsgBox "Better luck next time", , "Sorry"
End If
'_____________________________________________________________________________________________________________________


Cells(8, 2) = ("What two properties should be set for each command button?") 'Question 3
MsgBox ("What two properties should be set for each command button?"), , "Question 3"

Cells(9, 3) = ("Name, Caption") 'Answer 3
MsgBox "Name, Caption", , "Answer"
MsgBox "Did you get it right?", vbYesNo, "Did you get it right?"
If returnvalue = yes Then
MsgBox "Congratulations", , "Good Job"
Cells(15, 6) = Val(numRight) + 1
Else
MsgBox "Better luck next time", , "Sorry"
End If
'_____________________________________________________________________________________________________________________

Cells(10, 2) = ("What command is used to place data into the worksheet?") 'Question 4
MsgBox ("What command is used to place data into the worksheet?"), , "Question 4"

Cells(11, 3) = ("Cells()") 'Answer 4
MsgBox "Cells()", , "Answer"
MsgBox "Did you get it right?", vbYesNo, "Did you get it right?"
If returnvalue = yes Then
MsgBox "Congratulations", , "Good Job"
Cells(15, 6) = Val(numRight) + 1
Else
MsgBox "Better luck next time", , "Sorry"
End If
'_____________________________________________________________________________________________________________________

Cells(12, 2) = ("What button(s) appears on a dialog box ( Go, Cancel, Stop, OK, Start)?") 'Question 5
MsgBox ("What button(s) appears on a dialog box (Go, Cancel, Stop, OK, Start)?"), , "Question 5"

Cells(13, 3) = ("OK") 'Answer 5
MsgBox "OK", , "Answer"
MsgBox "Did you get it right?", vbYesNo, "Did you get it right?"
If returnvalue = yes Then
MsgBox "Congratulations", , "Good Job"
Cells(15, 6) = Val(numRight) + 1
Else
MsgBox "Better luck next time", , "Sorry"
End If

End Sub
[/code]
Sign In or Register to comment.