Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to evaluate VB constant name in string variable?

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to evaluate VB constant name in string variable?

Try

i = VAL(sMyString)

--

Regards,
Nigel




"G Lykos" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to evaluate VB constant name in string variable?

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" wrote in message
...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to evaluate VB constant name in string variable?

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@discussions wrote in message
...
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" wrote in message
...
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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to evaluate VB constant name in string variable?

Thanks for the suggestion. Consistently evaluates to 0 when applied to
string variables containing VB constant names.


"Nigel" wrote in message
...
Try

i = VAL(sMyString)

--

Regards,
Nigel




"G Lykos" wrote in message
...
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







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to evaluate VB constant name in string variable?

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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to evaluate VB constant name in string variable?

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@discussions wrote in message
...
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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How to evaluate VB constant name in string variable?

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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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












  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default How to evaluate VB constant name in string variable?

In fact, please stop here; see posting of the reframed question (looking to
reach the general public).


"Peter T" <peter_t@discussions wrote in message
...
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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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@discussions wrote in message
...
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" wrote in message
...
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














Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF evaluate string output David Excel Programming 9 September 9th 08 08:02 AM
Evaluate a Variable Name from a String Developer of the Caribbean Excel Programming 4 November 11th 05 07:50 AM
How to evaluate string? Boban Excel Programming 4 November 4th 05 06:21 PM
Evaluate string as a formula peacelittleone Excel Worksheet Functions 3 June 26th 05 06:20 PM
converting constant/text to formula and evaluate it tsuoying Excel Programming 1 February 19th 05 04:28 PM


All times are GMT +1. The time now is 03:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"