TheFlatTire
New Member
- Joined
- Mar 20, 2023
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hi all,
I have been trying to make an excel quiz application that will quiz my peers based on the images that appear. All runs smoothly, except I cannot get the images to change dynamically with in my user form. I do not want to have to reference local files (because many of them won't have them saved), so all of the images are stored on the quiz "master sheet". At the moment I have the image I wish to display running an index off of the question number in a separate work sheet. I pasted this indexed image which functions properly on the worksheet into my quiz user form. When operating the user form the image stays as the image that I pasted and won't change as the quiz advances unlike how it behaves on the worksheet. Is there a way to have the picture property of the image control refresh to the new image automatically?
I apologize if this makes no sense, I am very new to VBA. Thank you for any guidance.
______________________________________________________________
Sub get_quiz()
Call resetButton
Dim lRow As Integer
lRow = questionNo + 1
question = qSH.Range("A" & lRow).Value
Worksheets("Question Image").Range("A1").Value = question
' This pastes the name of the answer that the image indexes from for each question.
code = qSH.Range("B" & lRow).Value
choiceA = qSH.Range("C" & lRow).Value
choiceB = qSH.Range("D" & lRow).Value
choiceC = qSH.Range("E" & lRow).Value
choiceD = qSH.Range("F" & lRow).Value
answer = qSH.Range("G" & lRow).Value
txtQuestion.Value = question
txtSampleCode.Value = code
cmdA.Caption = choiceA
cmdB.Caption = choiceB
cmdC.Caption = choiceC
cmdD.Caption = choiceD
If questionNo = 20 Then
'Last question
cmdSubmit.Caption = "End Exam"
End If
End Sub
________________________________________________________________
I have been trying to make an excel quiz application that will quiz my peers based on the images that appear. All runs smoothly, except I cannot get the images to change dynamically with in my user form. I do not want to have to reference local files (because many of them won't have them saved), so all of the images are stored on the quiz "master sheet". At the moment I have the image I wish to display running an index off of the question number in a separate work sheet. I pasted this indexed image which functions properly on the worksheet into my quiz user form. When operating the user form the image stays as the image that I pasted and won't change as the quiz advances unlike how it behaves on the worksheet. Is there a way to have the picture property of the image control refresh to the new image automatically?
I apologize if this makes no sense, I am very new to VBA. Thank you for any guidance.
______________________________________________________________
Sub get_quiz()
Call resetButton
Dim lRow As Integer
lRow = questionNo + 1
question = qSH.Range("A" & lRow).Value
Worksheets("Question Image").Range("A1").Value = question
' This pastes the name of the answer that the image indexes from for each question.
code = qSH.Range("B" & lRow).Value
choiceA = qSH.Range("C" & lRow).Value
choiceB = qSH.Range("D" & lRow).Value
choiceC = qSH.Range("E" & lRow).Value
choiceD = qSH.Range("F" & lRow).Value
answer = qSH.Range("G" & lRow).Value
txtQuestion.Value = question
txtSampleCode.Value = code
cmdA.Caption = choiceA
cmdB.Caption = choiceB
cmdC.Caption = choiceC
cmdD.Caption = choiceD
If questionNo = 20 Then
'Last question
cmdSubmit.Caption = "End Exam"
End If
End Sub
________________________________________________________________