|
-
Jul 13th, 2001, 07:47 AM
#1
Thread Starter
Fanatic Member
Question
I am making a game where i needed to be able to have the users score from form 4 to move to form 5 etc. Thanks to you guys I was able to accomplish this. However, the problem is that even though I was able to get the score to move from form4 to form5 when I insert the code for if the user clicks the right or wrong image to and ten points or subtract points when you click the image the users score that came from form4 to form5 goes back to zero. So I was wondering if anyone knows a code that I can use so that the users score from form4 once it goes to form5 and the user clicks on the right or wrong image they will lose ten points or have ten points added to their current score that was brought from form 4. Example: The user's score was 110 in form4 if the user clicks the right image in form5 I want ten points to added to their score of 110. If they click the wrong image I want their score to lose ten points.
Here is the code i used to get the score to go to form5 :
form5.label1.caption= form4.label1.caption
here is the code for if the users clicks the correct image:
image1.tag="clicked"
score=score+10
label1.caption= score
And here is the score I used if they click the wrong image
image2.tag="clicked"
score=score-10
label1.caption= score
So can someone please help me get the users score from form4 to be added onto in form5 or subtracted from if they click the right or wrong image.
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 07:50 AM
#2
Addicted Member
AFTER updating the Score
form5.label1.caption = score
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
-
Jul 13th, 2001, 07:52 AM
#3
Thread Starter
Fanatic Member
where
where do I insert the code form5.caption= score and what do you mean by after updating the form?
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 07:57 AM
#4
Addicted Member
Correct Image
image1.tag="clicked"
score=score+10
label1.caption= score
form5.label1.caption = score
Wrong Image
image2.tag="clicked"
score=score-10
label1.caption= score
form5.label1.caption = score
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
-
Jul 13th, 2001, 08:04 AM
#5
Thread Starter
Fanatic Member
Thanks
Thanks Nicres you have been a great help I have one question though how long if you been working with visual basics and how old were you when you started working on it?
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 08:19 AM
#6
Member
Walter100, if you're going to be programming, you shouldn't be just accepting the default names for controls! Instead of Form1, use frmMain, Image1 should be imgWhatever, etc. It will make your code easier for others (and you) to understand. Just a thought, no criticism intended.
-
Jul 13th, 2001, 08:35 AM
#7
Fanatic Member
A much easier way to store the score without having to pass the variable directly based on formname?
Add a Code module to your project.
In the Code Module, Add the Following Lines:
Code:
Public Score As Integer
'In whichever form you have a label that holds the score:
Private Sub UpdateScore(Amount As Integer)
Score = Score + Amount
lblScore.Catption = Score
End Sub
Score increases:
UpdateScore 10
Score Decreases
UpdateScore -10
Hope this makes your coding a bit easier 
You could also put UpdateScore in the module as well:
Code:
Public Score As Integer
Public Sub UpdateScore(Amount As Integer, frmForm As Form)
Score = Score + Amount
frmForm.lblScore.Caption = Score
End Sub
Usage:
Score Increases: UpdateScore 10, Me
Score Decreases: UpdateScore -10, Me
You'll have to have a label named the same thing on each form. IE: on form1 you have lblScore, on form4 you have lblScore, on form6 you have lblScore. Should make your process much faster and all you have to reference is the subroutine.
Last edited by ExcalibursZone; Jul 13th, 2001 at 08:39 AM.
-Excalibur
-
Jul 13th, 2001, 09:29 AM
#8
Thread Starter
Fanatic Member
question
Iam sixteen and I am currently reading a book on visual basics. I am learning alot at first I did not use the book I would just use the toolbox to do projects until I realized I need to use codes. I learned html when I was 12 and I have created a few websites If anyone wants to see one of my current ones here is the address: http://members.tripod.com/~striver2000/links.html I want to know what do I need to do to really get a grasp on concepts of visiual basics like 3d games and stuff of that nature. The reason being, is that alot of people on here know a whole lot about visiual basics how long did it take for you to obtain this knowledge and how were you when you started, and how can I grasp this knowledge?
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 09:34 AM
#9
-
Jul 13th, 2001, 12:32 PM
#10
Thread Starter
Fanatic Member
thanks
Thanks for that so you did start off pretty early did you find any of the information pretty confusing at first.
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 01:34 PM
#11
Member
I never did dot notatation or OOP (Object Oriented Programming) before, or any GUI programming. But since I started early and had a similar language as a base, I didn't have any real problems. I just started small.
-
Jul 13th, 2001, 02:30 PM
#12
Thread Starter
Fanatic Member
question
what was the other language that you started off with?
Walter Richardson
Striver2000 Christian Productions
Iam seventeen but since I started VB in June of 01 GOD has been helping me excell by finding this great forum with a bunch of GREAT PEOPLE!
-
Jul 13th, 2001, 02:54 PM
#13
Member
QBasic, like I said. Then I learned VB, then C++, then Java. I also learned JavaScript, but that is so not powerful that it doesn't count. I also know HTML and JSP, and the version of BASIC for my calculator.
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
|