Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Dynamic Variable declaration

Dynamic Variable declaration

Scheduled Pinned Locked Moved The Lounge
helptutorialquestion
16 Posts 13 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Chamu Matumbura

    Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

    Reuse! Buy If You Can! Build If You Must

    N Offline
    N Offline
    NormDroid
    wrote on last edited by
    #6

    :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: :laugh: It's the way you tell 'em.

    Software Kinetics (requires SL3 beta) - Moving software

    1 Reply Last reply
    0
    • C Chamu Matumbura

      Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

      Reuse! Buy If You Can! Build If You Must

      D Offline
      D Offline
      Dalek Dave
      wrote on last edited by
      #7

      Flame on! If you cannot read why are you attempting to program?

      ------------------------------------ "Men may make bad decisions, immoral decisions or just plain wrong decisions, but at least they make decisions. Women on the other hand..." Patrick Kielty 2006

      1 Reply Last reply
      0
      • J Jim Crafton

        Are you using your high midichlorian count to help ascertain this? Or just a lucky guess? :)

        ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

        D Offline
        D Offline
        Dalek Dave
        wrote on last edited by
        #8

        I gotta bad feeling about this!

        ------------------------------------ "Men may make bad decisions, immoral decisions or just plain wrong decisions, but at least they make decisions. Women on the other hand..." Patrick Kielty 2006

        L 1 Reply Last reply
        0
        • J Jim Crafton

          Are you using your high midichlorian count to help ascertain this? Or just a lucky guess? :)

          ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

          S Offline
          S Offline
          Steve Dubyo
          wrote on last edited by
          #9

          Just a wild stab in the dark but I'm feeling lucky!!

          ;-]

          1 Reply Last reply
          0
          • D Dalek Dave

            I gotta bad feeling about this!

            ------------------------------------ "Men may make bad decisions, immoral decisions or just plain wrong decisions, but at least they make decisions. Women on the other hand..." Patrick Kielty 2006

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #10

            I've got a good feeling about it because I know why you've got a bad feeling about it. :laugh:

            Visit http://www.notreadytogiveup.com/[^] and do something special today.

            1 Reply Last reply
            0
            • C Chamu Matumbura

              Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

              Reuse! Buy If You Can! Build If You Must

              D Offline
              D Offline
              Dave Parker
              wrote on last edited by
              #11

              Maybe I'm misunderstanding what you're trying to do, but use an array?

              1 Reply Last reply
              0
              • C Chamu Matumbura

                Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

                Reuse! Buy If You Can! Build If You Must

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #12

                You aren't making any.

                Chamu Matumbura wrote:

                Here is the logic

                I'm afraid not.

                1 Reply Last reply
                0
                • C Chamu Matumbura

                  Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

                  Reuse! Buy If You Can! Build If You Must

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #13

                  Use XML. That should solve the problem. ;) Marc

                  Will work for food. Interacx

                  I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

                  0 I 2 Replies Last reply
                  0
                  • M Marc Clifton

                    Use XML. That should solve the problem. ;) Marc

                    Will work for food. Interacx

                    I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

                    0 Offline
                    0 Offline
                    0x3c0
                    wrote on last edited by
                    #14

                    No no no no no. That's insecure. Use a Caesar shift to make it unbreakable! :laugh:

                    OSDev

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      Use XML. That should solve the problem. ;) Marc

                      Will work for food. Interacx

                      I'm not overthinking the problem, I just felt like I needed a small, unimportant, uninteresting rant! - Martin Hart Turner

                      I Offline
                      I Offline
                      Iain Clarke Warrior Programmer
                      wrote on last edited by
                      #15

                      Not liquid nitrogen? I hear that's useful... Iain.

                      I have now moved to Sweden for love (awwww). If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

                      1 Reply Last reply
                      0
                      • C Chamu Matumbura

                        Hie guys. I want to know if it is possible to declare variables at runtime in VB. Here is the logic trying to be achieved: Say you have a variable that you want to create out of a value in a table and then use it later in code, is it possible? Example: Table containing names: Animal Height Weight Color ------ ------ ------ ----- Dog 40 30 Brown Cat 20 3 Black ....... Then in your code you want to create a variable out of an animal name. To do this you will have a recordset or dataset with the animal atributes as shown above. The objective is to end up having variable names based on the Animal field, accommodating for new animals to be added, at runtime. From the above rows, the runtime code should create variables strDog and strCat. If any other animal, say XX, is added the same code should be able to create a variable strXX. Is this possible? Help please.

                        Reuse! Buy If You Can! Build If You Must

                        T Offline
                        T Offline
                        TheGreatAndPowerfulOz
                        wrote on last edited by
                        #16

                        The dog will eat the cat and the cow will jump over the moon

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups