Results 1 to 13 of 13

Thread: Question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  2. #2
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    AFTER updating the Score

    form5.label1.caption = score
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    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!

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    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...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  6. #6
    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.

  7. #7
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    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

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  9. #9
    Wow. So many questions.

    I learned from the tutorial book that came with VB3 standard. But I learned good ol' QBasic at an early age. I recommend books by Sams Publishing. Every book I have bought from them is excellent and detailed with examples and the occasional screenshot. Don't get that In A Nutshell crap (here come the flames ). Also, VB5 (but I don't think 6) has a proggie called Books Online, which has tutorials for ActiveX development and other topics.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    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!

  11. #11
    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.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2001
    Location
    Baltimore,MD
    Posts
    536

    Talking 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!

  13. #13
    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
  •  



Click Here to Expand Forum to Full Width