From: Peter T on 11 Feb 2010 12:01 If s = "vbOK" then n = 1 elseif etc or Select Case s Case "vbOK": n = 1 etc You didn't explain the context of your question, there might be a different approach. Regards, Peter T "G Lykos" <GLykos(a)CompuServe.com> wrote in message news:ep5b$KzqKHA.4284(a)TK2MSFTNGP04.phx.gbl... > Okay - how about vbOK/1. Are you familiar with a mechanism to evaluate > the VB constant name in a string variable? > > Thanks! > > > "Peter T" <peter_t(a)discussions> wrote in message > news:eYKRNwxqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >> What's the context of your question >> >> vbOkay - no such named constant, maybe you mean vbYes/6 or vbOK/1 >> >> Regards, >> Peter T >> >> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >> news:%23iVJr8tqKHA.3408(a)TK2MSFTNGP06.phx.gbl... >>> Greetings! >>> >>> Example: the value of vbOkay within the VBE is 6. {i = vbOkay} yields >>> i = 6. >>> >>> Would like a construct where {sMyString = "vbOkay" : i = >>> UnknownFunction(sMyString)} yields i = 6 >>> >>> TIA! >>> George >>> >>> >> >> > >
From: G Lykos on 11 Feb 2010 14:55 Thanks. The idea was to avoid having to look up and hard-code a bunch of system constants that I already know by name. If you can go into the VBE Immediate window, enter '? vbOK', and get back '1' on the fly, then you'd think that VBA would be able to handle run-time evaluation of system constants by name reference within module code. Any other ideas? "Peter T" <peter_t(a)discussions> wrote in message news:uS7%23ivzqKHA.3536(a)TK2MSFTNGP06.phx.gbl... > If s = "vbOK" then > n = 1 > elseif > etc > > or > Select Case s > Case "vbOK": n = 1 > etc > > You didn't explain the context of your question, there might be a > different approach. > > Regards, > Peter T > > "G Lykos" <GLykos(a)CompuServe.com> wrote in message > news:ep5b$KzqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >> Okay - how about vbOK/1. Are you familiar with a mechanism to evaluate >> the VB constant name in a string variable? >> >> Thanks! >> >> >> "Peter T" <peter_t(a)discussions> wrote in message >> news:eYKRNwxqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >>> What's the context of your question >>> >>> vbOkay - no such named constant, maybe you mean vbYes/6 or vbOK/1 >>> >>> Regards, >>> Peter T >>> >>> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >>> news:%23iVJr8tqKHA.3408(a)TK2MSFTNGP06.phx.gbl... >>>> Greetings! >>>> >>>> Example: the value of vbOkay within the VBE is 6. {i = vbOkay} yields >>>> i = 6. >>>> >>>> Would like a construct where {sMyString = "vbOkay" : i = >>>> UnknownFunction(sMyString)} yields i = 6 >>>> >>>> TIA! >>>> George >>>> >>>> >>> >>> >> >> > >
From: Peter T on 11 Feb 2010 15:59 But VBA can indeed evaluate named constants (assuming it can find the relevant library), that's the whole point of them, eg result = MsgBox("yes+no+cancel=" & (vbYes + vbNo + vbCancel), vbYesNoCancel) If result = vbYes Then s = "yes " & vbyes ElseIf result = vbNo Then s = "no " & vbno ElseIf result = vbCancel Then s = "cancel " & vbcancel End If MsgBox s Maybe I'm missing what you're trying to do Regards, Peter T "G Lykos" <GLykos(a)CompuServe.com> wrote in message news:%23oh5mQ1qKHA.4236(a)TK2MSFTNGP02.phx.gbl... > Thanks. The idea was to avoid having to look up and hard-code a bunch of > system constants that I already know by name. If you can go into the VBE > Immediate window, enter '? vbOK', and get back '1' on the fly, then you'd > think that VBA would be able to handle run-time evaluation of system > constants by name reference within module code. Any other ideas? > > > "Peter T" <peter_t(a)discussions> wrote in message > news:uS7%23ivzqKHA.3536(a)TK2MSFTNGP06.phx.gbl... >> If s = "vbOK" then >> n = 1 >> elseif >> etc >> >> or >> Select Case s >> Case "vbOK": n = 1 >> etc >> >> You didn't explain the context of your question, there might be a >> different approach. >> >> Regards, >> Peter T >> >> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >> news:ep5b$KzqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >>> Okay - how about vbOK/1. Are you familiar with a mechanism to evaluate >>> the VB constant name in a string variable? >>> >>> Thanks! >>> >>> >>> "Peter T" <peter_t(a)discussions> wrote in message >>> news:eYKRNwxqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >>>> What's the context of your question >>>> >>>> vbOkay - no such named constant, maybe you mean vbYes/6 or vbOK/1 >>>> >>>> Regards, >>>> Peter T >>>> >>>> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >>>> news:%23iVJr8tqKHA.3408(a)TK2MSFTNGP06.phx.gbl... >>>>> Greetings! >>>>> >>>>> Example: the value of vbOkay within the VBE is 6. {i = vbOkay} >>>>> yields i = 6. >>>>> >>>>> Would like a construct where {sMyString = "vbOkay" : i = >>>>> UnknownFunction(sMyString)} yields i = 6 >>>>> >>>>> TIA! >>>>> George >>>>> >>>>> >>>> >>>> >>> >>> >> >> > >
From: G Lykos on 13 Feb 2010 16:44 In fact, please stop here; see posting of the reframed question (looking to reach the general public). "Peter T" <peter_t(a)discussions> wrote in message news:%23kd8W01qKHA.5036(a)TK2MSFTNGP02.phx.gbl... > But VBA can indeed evaluate named constants (assuming it can find the > relevant library), that's the whole point of them, eg > > result = MsgBox("yes+no+cancel=" & (vbYes + vbNo + vbCancel), > vbYesNoCancel) > If result = vbYes Then > s = "yes " & vbyes > ElseIf result = vbNo Then > s = "no " & vbno > ElseIf result = vbCancel Then > s = "cancel " & vbcancel > End If > MsgBox s > > Maybe I'm missing what you're trying to do > > Regards, > Peter T > > > "G Lykos" <GLykos(a)CompuServe.com> wrote in message > news:%23oh5mQ1qKHA.4236(a)TK2MSFTNGP02.phx.gbl... >> Thanks. The idea was to avoid having to look up and hard-code a bunch of >> system constants that I already know by name. If you can go into the VBE >> Immediate window, enter '? vbOK', and get back '1' on the fly, then you'd >> think that VBA would be able to handle run-time evaluation of system >> constants by name reference within module code. Any other ideas? >> >> >> "Peter T" <peter_t(a)discussions> wrote in message >> news:uS7%23ivzqKHA.3536(a)TK2MSFTNGP06.phx.gbl... >>> If s = "vbOK" then >>> n = 1 >>> elseif >>> etc >>> >>> or >>> Select Case s >>> Case "vbOK": n = 1 >>> etc >>> >>> You didn't explain the context of your question, there might be a >>> different approach. >>> >>> Regards, >>> Peter T >>> >>> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >>> news:ep5b$KzqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >>>> Okay - how about vbOK/1. Are you familiar with a mechanism to evaluate >>>> the VB constant name in a string variable? >>>> >>>> Thanks! >>>> >>>> >>>> "Peter T" <peter_t(a)discussions> wrote in message >>>> news:eYKRNwxqKHA.4284(a)TK2MSFTNGP04.phx.gbl... >>>>> What's the context of your question >>>>> >>>>> vbOkay - no such named constant, maybe you mean vbYes/6 or vbOK/1 >>>>> >>>>> Regards, >>>>> Peter T >>>>> >>>>> "G Lykos" <GLykos(a)CompuServe.com> wrote in message >>>>> news:%23iVJr8tqKHA.3408(a)TK2MSFTNGP06.phx.gbl... >>>>>> Greetings! >>>>>> >>>>>> Example: the value of vbOkay within the VBE is 6. {i = vbOkay} >>>>>> yields i = 6. >>>>>> >>>>>> Would like a construct where {sMyString = "vbOkay" : i = >>>>>> UnknownFunction(sMyString)} yields i = 6 >>>>>> >>>>>> TIA! >>>>>> George >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> >>> >>> >> >> > >
First
|
Prev
|
Pages: 1 2 Prev: using lookup function in vba Next: Macro needs to rename worksheet tab name |