Easy Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Cooney

    Easy Question

    Ok

    I have a class called Game which has an GameID value.

    I also have a routine that runs every 6 seconds. I need to see if the object
    Game exists with an GameID value = to the value of the Game that is
    currently running, if it is i need to update values within that object if
    not create a new object.

    Any easy code?


  • rowe_newsgroups

    #2
    Re: Easy Question

    On Feb 24, 2:48 am, "Mark Cooney" <m...@mcooney.c o.ukwrote:
    Ok
    >
    I have a class called Game which has an GameID value.
    >
    I also have a routine that runs every 6 seconds. I need to see if the object
    Game exists with an GameID value = to the value of the Game that is
    currently running, if it is i need to update values within that object if
    not create a new object.
    >
    Any easy code?
    A simple way is to use a shared property in the Game class that keeps
    a list of Game instances using a key/value pair. Store the GameID of
    an instance as the key, and the actual instance as the value. Then a
    simple if MyGameList.Cont ains(myGameId) then... should give you the
    functionality you require.

    Thanks,

    Seth Rowe

    Comment

    • Stephany Young

      #3
      Re: Easy Question

      If myGame Is Nothing orElse myGame.GameID <runningGameI D Then
      myGame = New Game
      myGame.GameID = runningGameID
      End if

      'Update other properties of myGame


      "Mark Cooney" <mark@mcooney.c o.ukwrote in message
      news:%23ETU6g%2 3VHHA.496@TK2MS FTNGP06.phx.gbl ...
      Ok
      >
      I have a class called Game which has an GameID value.
      >
      I also have a routine that runs every 6 seconds. I need to see if the
      object Game exists with an GameID value = to the value of the Game that is
      currently running, if it is i need to update values within that object if
      not create a new object.
      >
      Any easy code?
      >

      Comment

      • yhlove@gmail.com

        #4
        Re: Easy Question

        On Feb 24, 9:48 am, "Mark Cooney" <m...@mcooney.c o.ukwrote:
        Ok
        >
        I have a class called Game which has an GameID value.
        >
        I also have a routine that runs every 6 seconds. I need to see if the object
        Game exists with an GameID value = to the value of the Game that is
        currently running, if it is i need to update values within that object if
        not create a new object.
        >
        Any easy code?
        Hi

        Could you tell me please how did you make a functions which runs every
        6 seconds ??
        I need to do somthing similar in my project.

        Thanks
        Yhlove

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Easy Question

          Yhlove,

          Please don't ask questions connected to another question. It makes it
          confusing for those who are searching this newsgroup as is often done using
          Google. This is a 7 days a week 24 hours newsgroup done by people all over
          the world so your answer will be there if it is known.

          Cor

          <yhlove@gmail.c omschreef in bericht
          news:1172332863 .226487.23320@z 35g2000cwz.goog legroups.com...
          On Feb 24, 9:48 am, "Mark Cooney" <m...@mcooney.c o.ukwrote:
          >Ok
          >>
          >I have a class called Game which has an GameID value.
          >>
          >I also have a routine that runs every 6 seconds. I need to see if the
          >object
          >Game exists with an GameID value = to the value of the Game that is
          >currently running, if it is i need to update values within that object if
          >not create a new object.
          >>
          >Any easy code?
          >
          Hi
          >
          Could you tell me please how did you make a functions which runs every
          6 seconds ??
          I need to do somthing similar in my project.
          >
          Thanks
          Yhlove
          >

          Comment

          • Tom Leylan

            #6
            Re: Easy Question

            Just wanted to say you can safely ignore Cor's reply. The newsgroup does
            not exist to make Google happy, nor does it exist to support the needs of
            some unknown number of people who at some unnamed point in the future
            require some unknown piece of information.

            If you have a question, post it as you've done. Thread topics migrate all
            the time, not only this week but for the more than 520 weeks I've been
            contributing to them.

            <yhlove@gmail.c omwrote in message
            news:1172332863 .226487.23320@z 35g2000cwz.goog legroups.com...
            Could you tell me please how did you make a functions which runs every
            6 seconds ??
            I need to do somthing similar in my project.
            >
            Thanks
            Yhlove

            Comment

            • Tom Leylan

              #7
              Re: Easy Question

              "Mark Cooney" <mark@mcooney.c o.ukwrote:
              I have a class called Game which has an GameID value.
              >
              I also have a routine that runs every 6 seconds. I need to see if the
              object Game exists with an GameID value = to the value of the Game that is
              currently running, if it is i need to update values within that object if
              not create a new object.
              >
              Any easy code?
              Mark: There isn't quite enough information.

              Are there multiple games running (which is what it sounds like to me)? If
              that is the case then what is missing is another Class/Object which is a
              game manager. Seth alludes to a solution but I think it would be a mistake
              to add such a list to the Game class. A game isn't a collection of games.
              And surely you will add methods and properties to a GameManager class which
              have no business being in a Game object.

              The GameManager would instantiate new games, remove old games, monitor games
              and should even take care of your 6 second notification (with the value 6)
              being a property of the GameManager so you could change it without editing
              the Button Click event that contains a hard coded 6.

              Now that you have a GameManager class you have the ability to create
              multiple GameManager objects if necessary.

              Tom


              Comment

              • Mark Cooney

                #8
                Re: Easy Question

                Thanks all

                I did a figure a way to do thanks to rowe and stephany and a mixture of both
                ways . and yh, just for your info i used a timer set to 6000.


                "Tom Leylan" <tleylan@nospam .netwrote in message
                news:uFpgkwDWHH A.4260@TK2MSFTN GP06.phx.gbl...
                "Mark Cooney" <mark@mcooney.c o.ukwrote:
                >
                >I have a class called Game which has an GameID value.
                >>
                >I also have a routine that runs every 6 seconds. I need to see if the
                >object Game exists with an GameID value = to the value of the Game that
                >is currently running, if it is i need to update values within that object
                >if not create a new object.
                >>
                >Any easy code?
                >
                Mark: There isn't quite enough information.
                >
                Are there multiple games running (which is what it sounds like to me)? If
                that is the case then what is missing is another Class/Object which is a
                game manager. Seth alludes to a solution but I think it would be a
                mistake to add such a list to the Game class. A game isn't a collection
                of games. And surely you will add methods and properties to a GameManager
                class which have no business being in a Game object.
                >
                The GameManager would instantiate new games, remove old games, monitor
                games and should even take care of your 6 second notification (with the
                value 6) being a property of the GameManager so you could change it
                without editing the Button Click event that contains a hard coded 6.
                >
                Now that you have a GameManager class you have the ability to create
                multiple GameManager objects if necessary.
                >
                Tom
                >
                >

                Comment

                Working...