471,853 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

creating a custom Message Box


I want to create a Custom Message box where the label and buttons have variable text in them.
I need to run a subroutine that calls the message box and if the answer is yes does 1 thing and if it's no it does nothing.
The problem is I can't get the subroutine to wait for the answer from the other form.
Can someone guide me as to how to load the form get the result and feed the result back to the main form subroutine.
By the way the Message Form as txtlabels and commandbutton labels defined as variables which work fine.

Jan 16 '07 #1
5 5749
I thought I would add this to make sense of my question.

Subroutine sets the caption for the message form i.e. "Are you sure"
Sets the name on the buttons for the message form i.e. "Yes" or "No"

The problem is when I press the "No" button on the Message form I want to return to the subroutine that called the message form and use the answer to carry on in the first form

I hope this makes some sense.

Jan 16 '07 #2
I have found the solution using the CallByName function.
Jan 16 '07 #3
8,435 Expert 8TB
I have found the solution using the CallByName function.
I'm not familiar with CallByName, but had I read your question earlier I would have said to show the message form modally. In other words (VB6 code)...
Expand|Select|Wrap|Line Numbers
  1. MessageForm.Show vbModal
This doesn't allow control to return until the form is closed (or hidden, I think).
Jan 16 '07 #4
Thanks for you note I might need it latter on in the project. I wanted to go back to the same sub because I was creating a variable which had the name of a procedure. In other words if the answer was yes the variable would have the name of procedure 1 and if no the variable would have the procedure name 2. As I needed to have a lot of these Message Boxes for a lot of different procedures I didn't want to use loads of Message Box forms. Instead I was able to set the name of the procedure in a variable call the message box form call a result procedure in the orginal form and with the CallByName procedure able to call the next procedure using a variable instead of the specific procedure name. CallByName works like this
CallByName object where the procedure is, variable containing name of the procedure, vbMethod
I hope this helps someone else.

Jan 17 '07 #5
8,435 Expert 8TB
Thanks for that, Frank.

Glad to hear you resolved your problem. And yes, hopefully this will be a useful addition to the great storehouse of information here at TheScripts. (I know I'll be filing away the CallByName to have a look at when I find the time.:))
Jan 17 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by NutJob | last post: by
15 posts views Thread by Carlos Lozano | last post: by
3 posts views Thread by clsmith66 | last post: by
17 posts views Thread by Lee Harr | last post: by
3 posts views Thread by =?Utf-8?B?R2hpc3Rvcw==?= | last post: by
1 post views Thread by =?Utf-8?B?QXJ0aHVyIFBhcmtlcg==?= | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.