Hi there,
I'm fairly new to VBA, so I am not sure this is possible, but it seems like it should be... I am working on a Jeopardy project. I found a free template with scoring online, but there was no Final Jeopardy option, so I've been trying to code that in. The other scoring is fairly straightfoward - objects have been assigned macros which add 100, 200, or 300 points to the score variable.
For Final Jeopardy, the competitor (there's only one, so no need to worry about multiple teams for this) needs to be able to enter any point value. I created an ActiveX texbox control named "wager" in which this value could be input. I have defined a variable (Dim finalwager as long) for the final wager output. The issue is that I can't seem to find the right code to assign the value in the wager input box to finalwager.
I have a sample of the presentation available (3MB - too big to attach). It's a last-minute project, and the game is March 18 (tomorrow, joy) - I've been researching this problem for 3 days now with no luck. Thanks in advance for any assistance.
Comments
You've probably already worked this out but just in case here's my suggestion. Since I don't know what code you've written and how you've set up your forms and I haven't worked with PowerPoint VBA forms (just Word, Excel, and Access) I'm making the assumption that PowerPoint isn't any different.
' frmFinalJeopardy - User form that stores the "wager" field.
' In the main body of your code Load the User Form
Load frmFinalJeopardy
' If you know the Max Amount they can wager you can assign it to the field before you display the form to the user.
frmFinalJeopardy.wager = curMaxAvailable
' Display the form to the user
frmFinalJeopardy.Show
' Once the user has entered their wager and hit a command button on the form you can hide the form from the user but it stays in memory so you can still access the data on the form.
frmFinalJeopardy.Hide
' At this point you can check the value and make corrections (i.e., if they entered a negative number or more than they have to wager). You can use the same process above to change the value of the wager field, display an error message, and Show the form again so the user can make corrections.
' Assign the value from the wager field that's on the frmFinalJeopardy form to the finalwager variable.
'Val function will take the fields numeric value. If the user entered nothing or entered text it will 'display as 0.
'Format is just there to display the value as currency.
finalwager = Format(Val(frmFinalJeopardy.wager), "$#,000,000.00")
' Remove the form from memory
Unload frmFinalJeopardy
Hope that helps.
Bill
You've probably already worked this out but just in case here's my suggestion. Since I don't know what code you've written and how you've set up your forms and I haven't worked with PowerPoint VBA forms (just Word, Excel, and Access) I'm making the assumption that PowerPoint isn't any different.
' frmFinalJeopardy - User form that stores the "wager" field.
' In the main body of your code Load the User Form
Load frmFinalJeopardy
' If you know the Max Amount they can wager you can assign it to the field before you display the form to the user.
frmFinalJeopardy.wager = curMaxAvailable
' Display the form to the user
frmFinalJeopardy.Show
' Once the user has entered their wager and hit a command button on the form you can hide the form from the user but it stays in memory so you can still access the data on the form.
frmFinalJeopardy.Hide
' At this point you can check the value and make corrections (i.e., if they entered a negative number or more than they have to wager). You can use the same process above to change the value of the wager field, display an error message, and Show the form again so the user can make corrections.
' Assign the value from the wager field that's on the frmFinalJeopardy form to the finalwager variable.
'Val function will take the fields numeric value. If the user entered nothing or entered text it will 'display as 0.
'Format is just there to display the value as currency.
finalwager = Format(Val(frmFinalJeopardy.wager), "$#,000,000.00")
' Remove the form from memory
Unload frmFinalJeopardy
Hope that helps.
Bill