|
-
Aug 6th, 2009, 06:21 PM
#1
Thread Starter
Junior Member
-
Aug 6th, 2009, 08:56 PM
#2
Re: [VB.Net] Game Scoring System - How can I Do This?
well, how much is a correct question worth? do you lose points if you get one wrong? is there a target score to go to a different "level", or a neverending cumulating score? do the point values increase as you go on?
we need more info.
it's pretty easy to do, but you need to give us some more detailed information.
vb.net Code:
Dim score as Integer = 0
If answer Then
score += 1
Else
score -= 1
End if
-
Aug 7th, 2009, 09:56 AM
#3
Thread Starter
Junior Member
Re: [VB.Net] Game Scoring System - How can I Do This?
heres my code
Code:
Dim score As Integer = 0
TextBox2.Text = score
If Decimal.TryParse(TextBox1.Text, userAnswer) Then
If answer = userAnswer Then
score += 1
MsgBox("Congrats")
for some reason it just wont work.
-
Aug 7th, 2009, 09:59 AM
#4
Thread Starter
Junior Member
Re: [VB.Net] Game Scoring System - How can I Do This?
 Originally Posted by stateofidleness
well, how much is a correct question worth? do you lose points if you get one wrong? is there a target score to go to a different "level", or a neverending cumulating score? do the point values increase as you go on?
we need more info.
it's pretty easy to do, but you need to give us some more detailed information.
There are 10 questions in total (im not quite show how to only generate 10 as it just generates random forumales)
Each question is worth 1 point
There is no target sscore to go to a particular level; a message box will only appear stating congrats you got X mark out of 10 or something.
-
Aug 7th, 2009, 05:42 PM
#5
Thread Starter
Junior Member
Re: [VB.Net] Game Scoring System - How can I Do This?
-
Aug 7th, 2009, 06:36 PM
#6
Addicted Member
Re: [VB.Net] Game Scoring System - How can I Do This?
Maybe it is because you're initializing the score in the same procedure that you're adding it to?
I am assuming the snippet you posted is from the "Check Answer" [or something like that] button's Click event handler.
Here's how I would go about it:
Code:
'Declarations
Private score As Integer = 0
Private userAnswer As Decimal
'...Form Initialization Code...
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Decimal.TryParse(TextBox1.Text, userAnswer) Then
If answer = userAnswer Then
score += 1
TextBox2.Text = score
MsgBox("Congrats")
Else
MsgBox("Incorrect Answer")
End If
End If
End Sub
Anyone who has never made a mistake has never tried anything new. - Einstein
 Peace! 
-
Aug 7th, 2009, 07:48 PM
#7
Thread Starter
Junior Member
Re: [VB.Net] Game Scoring System - How can I Do This?
 Originally Posted by garyjohn_2000
Here's how I would go about it:
OMG Thankyou it worked 
1 more question
does anyone now how to implement a reset feature for example when the user does about 10 questions a message box appears stating that the user either has them all correct or has some wrong then it resets the counter, so that the user can start again.
cause currently the questions are infinite lol
thanks
edit: incase my explanation doesnt make sense, i provided a peice of code that boviously doesnt work (but i hope you get the general idea of what i mean )
Code:
If Button2.pressed = 10 Then
msgbox = scoreresult else
Reset(score)
Last edited by toshiba; Aug 7th, 2009 at 07:52 PM.
-
Aug 7th, 2009, 10:36 PM
#8
Re: [VB.Net] Game Scoring System - How can I Do This?
well what I would do is on form load call a "question generating" sub that would generate 10 questions with a for loop:
for x as Integer = 0 to 9
'create a question
'store it in an array at index i
next
Each time a question is asked, increment a questionCount variable by 1
then in the button's Click Event, you would check to see if questionCount = 10, if so, then call your msgbox.
to reset the score, just set the playersScore = 0 and call your "question generating" sub again.
-
Aug 8th, 2009, 11:31 AM
#9
New Member
Re: [RESOLVED] [VB.Net] Game Scoring System - How can I Do This?
the simplest can be is
if the answer is "dog" then
If Textbox1.Text = "dog" then
Score.Text = Score.Text + 1
else
// What ever you want :P
// Can be..
Score.Text = Score.Text - 1
End if
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|