|
-
Jul 27th, 2000, 01:24 PM
#1
Thread Starter
Member
OK, I am probably overlooking something really simple here, but...
Here is something similar to want I want to do:
Dim strMsg As String
Dim strTitle As String
Dim strOptions As String
Dim intReturn As Integer
strTitle = "Test"
strMsg = "blah blah blah"
strOptions = "vbOKCancel + vbExclamation"
intReturn = MsgBox(strMsg, strOptions, strTitle)
How can I get the string strOptions to be interpreted as:
vbOKCancel + vbExclamation
and not:
"vbOKCancel + vbExclamation" <- which of course causes a type mismatch error.
Thx,
~Michael Kizer
http://Michael.Kizer.ws
The Ivory Gate Of Dreams ~ http://www.ivorygate.com
-
Jul 27th, 2000, 01:38 PM
#2
_______
<?> get around the + operator
strOptions = "vbOKCancel" & " + " & "vbExclamation"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 27th, 2000, 01:42 PM
#3
New Member
I don't know if this would help, but I've run into simular situations with passing variables into statements that require a vb constant.. The work around I'd suggest is using a select case for it... ie:
Code:
Dim strMsg As String
Dim strTitle As String
Dim strOptions As String
Dim intReturn As Integer
strTitle = "Test"
strMsg = "blah blah blah"
select case strOptions
"vbOkCancel + vbExclamation"
intReturn = MsgBox(strMsg, vbOkCance + vbExclamation, strTitle)
End select
Now this would be if you didn't hard code the strOptions, but if you were actually passing that variable into this function/sub and it were going to change... You could just stick the possibilities into the case statement and pass it that way..
Hope this helps, if there is another way lemme know!
-
Jul 27th, 2000, 01:46 PM
#4
Fanatic Member
Are you trying to combine the two? Because if that is the case, you need to drop the quotes. Keep in mind, anything with a lowercase prefix of "vb" such as vbOKCancel is a reserve word.
Code:
intReturn = MsgBox(strMsg, vbOKCancel + vbExclamation, strTitle)
Chemically Formulated As:
Dr. Nitro
-
Jul 27th, 2000, 01:59 PM
#5
_______
<?>
'sorry, I misread your question 1st. time
'this will work for what you want.
Code:
Private Sub Form_Load()
Dim strMsg As String
Dim strTitle As String
Dim intReturn As Integer
Const strOptions = vbcancel + vbExclamation
strTitle = "Test"
strMsg = "blah blah blah"
intReturn = MsgBox(strMsg, strOptions, strTitle)
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jul 27th, 2000, 02:32 PM
#6
transcendental analytic
As a rule:
Always use OR when you add flags
Code:
intReturn = MsgBox(strMsg, vbcancel OR vbExclamation, strTitle)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 27th, 2000, 03:13 PM
#7
Thread Starter
Member
hmmm... not exactly what I had in mind...
The problem is that I am building the string var containing the named constants, dynamically. There could be hundreds of different combinations of them contained in the string. Once I have the string in the format I want, ie:
"vbOKCancel + vbExclamation + vbSystemModal + vbDefaultButton1" <- Or what ever...
Is there a way to make VB substitute the contents of the variable in the MsgBox function call, instead of trying to process the variable as a string var (which is illegal since that paramter of the function requires a numeric expression?
~Michael Kizer
http://Michael.Kizer.ws
The Ivory Gate Of Dreams ~ http://www.ivorygate.com
-
Jul 27th, 2000, 04:53 PM
#8
transcendental analytic
Sounds like you want to build a script,
You could do this
Code:
If string like "*vbOKCancel*" then Result=Result Or vbOKCancel
If string like "*vbExclamation*" then Result=Result Or vbExclamation
If string like "*vbSystemModal*" then Result=Result Or vbSystemModal
...
Which means you pass the Result (which is a integer) to the Msgbox
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|