Value of a "string"

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

    Value of a "string"

    Hi,
    can anyone help me with the following:

    Suppose I have a variable ll_temp containing pi and a variable test
    containing "ll_temp". Then with what syntax do I get the value of pi
    out of test ??

    ll_temp = 3.1415926
    test= "ll_temp"

    Thanks in advance,

    Jacco Struik
  • Bob Butler

    #2
    Re: Value of a "string&qu ot;

    "Jacco" <[email protected] t> wrote in message
    news:64d48731.0 309220715.72465 [email protected] gle.com[color=blue]
    > Hi,
    > can anyone help me with the following:
    >
    > Suppose I have a variable ll_temp containing pi and a variable test
    > containing "ll_temp". Then with what syntax do I get the value of pi
    > out of test ??
    >
    > ll_temp = 3.1415926
    > test= "ll_temp"[/color]

    VB doesn't have a direct way to do that. One option:

    dim c as collection
    set c=new collection
    c.add il_temp,"il_tem p"
    msgbox c.item(test)

    Comment

    • Rick Rothstein

      #3
      Re: Value of a &quot;string&qu ot;

      I see this type of question get asked a lot and I'm at a loss to understand
      why. I've been programming since 1981 and have yet to run into a need to do
      this type of indirection. After all, it could only be used successfully by
      the programmer him/herself... I mean, you can't expect the user to know to
      type in "ll_temp" into a TextBox in order for the program to go and get the
      value of PI hiding underneath it. So, if it would only be used by the
      programmer internally to his/her program, why not just use the variable
      ll_temp directly? Or, if there is some kind of variability required (having
      trouble imagining what), simply use a Select Case statement. And if needed
      more than a couple of times, set up a function that runs the Select Case
      instead so that you can pass in an argument indicating you want the value of
      PI. Maybe make the function take a String argument so "ll_temp" could be
      passed in even.<g>

      Rick - MVP

      "Bob Butler" <tiredofit@nosp am.com> wrote in message
      news:h1Ibb.1819 $gi2.485@fed1re ad01...[color=blue]
      > "Jacco" <[email protected] t> wrote in message
      > news:64d48731.0 309220715.72465 [email protected] gle.com[color=green]
      > > Hi,
      > > can anyone help me with the following:
      > >
      > > Suppose I have a variable ll_temp containing pi and a variable test
      > > containing "ll_temp". Then with what syntax do I get the value of pi
      > > out of test ??
      > >
      > > ll_temp = 3.1415926
      > > test= "ll_temp"[/color]
      >
      > VB doesn't have a direct way to do that. One option:
      >
      > dim c as collection
      > set c=new collection
      > c.add il_temp,"il_tem p"
      > msgbox c.item(test)
      >[/color]


      Comment

      • Stephane Richard

        #4
        Re: Value of a &quot;string&qu ot;

        VB doesn't do this kind of thing....also called macro substitution...

        Best way is to follow Bob's example.

        --
        Stéphane Richard
        "Ada World" Webmaster



        "Jacco" <[email protected] t> wrote in message
        news:64d48731.0 309220715.72465 [email protected] gle.com...[color=blue]
        > Hi,
        > can anyone help me with the following:
        >
        > Suppose I have a variable ll_temp containing pi and a variable test
        > containing "ll_temp". Then with what syntax do I get the value of pi
        > out of test ??
        >
        > ll_temp = 3.1415926
        > test= "ll_temp"
        >
        > Thanks in advance,
        >
        > Jacco Struik[/color]


        Comment

        • Bob Butler

          #5
          Re: Value of a &quot;string&qu ot;

          "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
          news:g6udnbpgZN [email protected] m[color=blue]
          > I see this type of question get asked a lot and I'm at a loss to
          > understand why. I've been programming since 1981 and have yet to run
          > into a need to do this type of indirection. After all, it could only
          > be used successfully by the programmer him/herself... I mean, you
          > can't expect the user to know to type in "ll_temp" into a TextBox[/color]

          I've dealt with a couple of cases where it would have come in handy; the
          controlling data (e.g. 'il_temp') was coming from a database or some other
          external source and the v alues to be used and/or actions to be taken depend
          on one or more of the input fields... it's not something I've run into often
          and I think many of the people asking it are doing so due more to limited
          experience with alternate methods than a real need for what they are asking
          for.

          Comment

          Working...