MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 25th, 2002, 08:31 AM   #1
elgringo56
Board Regular
 
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
Default

This is a really dumb one, I suppose, but I cant seem to ever find anything I need in the help section. I am trying to learn about message boxes. Typing Message box in help gets you nothing, but finally found that typing MsgBox got me the function. Now, I have figgured out how to get a box with data in it and two buttons, yes and no. What I cant seem to find is how to then do something depending on which I select. I assume selecting one gets me a value of 6 or 7, but I dont know how to then interogate for that value to perform dependant task? Some day I will learn this stuff, I hope. Thanks in advance for any help.
elgringo56 is offline   Reply With Quote
Old May 25th, 2002, 08:42 AM   #2
KLM
 
Join Date: May 2002
Posts: 5
Default

I would suggest that you buy a book.
KLM is offline   Reply With Quote
Old May 25th, 2002, 08:47 AM   #3
elgringo56
Board Regular
 
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
Default

Thats a pretty snotty remark, Klm, It happens that I live out of the country and cant get a book here in english, thank you.
elgringo56 is offline   Reply With Quote
Old May 25th, 2002, 08:49 AM   #4
KLM
 
Join Date: May 2002
Posts: 5
Default

Well, **** you. I was trying to be helpful.
KLM is offline   Reply With Quote
Old May 25th, 2002, 08:52 AM   #5
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
Default

Your question can be answered one of two ways. The simpler way is with an example like this:

Sub WorkMessageIf()
MsgBox "Do you want to leave work early today?", 36, "Question of the day:"
If vbYes Then
MsgBox "Then leave now before the boss returns!"
Else
MsgBox "Yuk, full day of work for the second time this year."
End If
End Sub

The second way is a bit more interesting because you asked about the number 6 and 7, which in message boxes are integer return values for vbYes and vbNo constants, respectively. So, here's another example, using those integers as answers:

Sub WorkMessageCase()
Dim Ans As Integer
Ans = MsgBox("Do you want to leave work early today?", 36, "Question of the day:")
Select Case Ans
Case Is = 6
MsgBox "Then leave now before the boss returns!"
Case Is = 7
MsgBox "Yuk, full day of work for the second time this year."
End Select
End Sub

Notice the number 36, which is 4 (an integer for the vbYesNo message box argument constant) plus 32 (the integer for the vbQuestion icon).

Hope this answers your question!
__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Old May 25th, 2002, 08:57 AM   #6
Tom Schreiner
Board Regular
 
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
Default

Here are several examples...



Sub ExampleMsgbox1()
Dim UserResponse

UserResponse = MsgBox("Please choose yes or no...", vbYesNo, "Msg Example")

If UserResponse = vbYes Then
'your code here if yes
Else
'your code if no
End If

End Sub


Sub ExampleMsgbox2()
Dim UserResponse

UserResponse = MsgBox("Please choose yes, no, or cancel...", vbYesNoCancel, "Msg Example")

Select Case UserResponse
Case vbYes
'your code if yes
Case vbNo
'your code if no
Case Else
'your code if cancel
End Select

End Sub


Tom
Tom Schreiner is offline   Reply With Quote
Old May 25th, 2002, 08:57 AM   #7
elgringo56
Board Regular
 
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
Default

Thank you very much, Tom. I am sorry to have such trivial questions at times, but I have no where else to turn for answers to them at this time, As KLM suggested, I do have some books being shipped to me, but it will be a while before they are here and I am trying to learn on my own in the mean time. Thanks again for your kind reply
elgringo56 is offline   Reply With Quote
Old May 25th, 2002, 09:01 AM   #8
elgringo56
Board Regular
 
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
Default

Also, thanks to you, TSTom, Seems I have several choices to choose from now. You guys are a great help.
elgringo56 is offline   Reply With Quote
Old May 25th, 2002, 09:03 AM   #9
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
Default

You are welcome (speaking for both Tom's here). When I started learning VBA I had this same question about message boxes. Examples like the ones from me and Tom should get you started. If not please post any follow-up question you need to; sharing information is what message boards are for.
__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Old May 25th, 2002, 09:38 AM   #10
KLM
 
Join Date: May 2002
Posts: 5
Default

Quote:
On 2002-05-25 08:03, Tom Urtis wrote:
You are welcome (speaking for both Tom's here). When I started learning VBA I had this same question about message boxes. Examples like the ones from me and Tom should get you started. If not please post any follow-up question you need to; sharing information is what message boards are for.

All very well, but as you know, the way for a beginner to really get to grips with VBA is to buy a book.

Augmenting VBA knowledge via boards like this is extremely useful, but it is not the way to learn VBA - it is merely a part of the process.

It is my opinion that little benefit is obtained by posters when they receive solutions to questions that work, but they understand nothing about why they work.

I see individuals on this board that have been asking simple VBA questions for a very long time - and many of them say that they're going to make the effort to learn some of it soon so they can reply instead of asking (what bullshit!).

Why not encourage the pursuit of knowledge rather than just providing the answer?
KLM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:21 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes