VBScript if button pressed...then

Status
Not open for further replies.

kpmwrestler

In Runtime
Messages
489
how would I do something like this

MsgBox"do you like pie?", 1, "Question"
*******something would go here to make it do this if "yes" is pressed: MsgBox"pie is good"

and something like this:MsgBox"why not?" if no is pressed


I know this is possible, but I can't get it to work also, can you do the same thing with InputBox?
 
well, you could do a button, txt entry, whatever. really depends. easiest is say one button was pushed it would be somethng like

msgbox ("blah blah blah")
end sub

or for text box you could have seomthing like
'we will say we called you texty box info

option explicit

DIM valhold as string

valhold=val.info.txt

if valhold = ("yes") then
msgbox "blah blah blah"
else
msgbox "blah blah blah"
end if

end sub


You could also add some error checking, like to make sure a value is only yes or no, if it is something else then you present another msgbox stating to only enter yes or no. I may be off on some of my entries there, haven't used vb in awhile and its hard to without the editor auto entering/checking stuff for me.
 
sorry, I meant if there was a box with yes or no (or any two buttons actually) and if the person clicks one, I know that the script can give a return value. is there a way to say if there is a certain return value, to do something?
 
well, you could do a nested if then statement, but the best thing to do instead of that is do a case select. Just create a global variable that takes the value of the text box and assigns it to said variable, then create a select case that performs an action according to what the value is.
 
alright, thanks, I was able to get it to work with msgbox, but with the inputbox it would be different. is there still a way to make it so if you press a button with the inputbox depending on the button you click, the response will be different?
 
yes, you would need a global (I think its called that) variable that puts whatever is in the input box into a string. This would be globaly available. Its not called global variable and cant remember what it is called but essentially, it is available via all subs.
 
Status
Not open for further replies.
Back
Top Bottom