![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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.
|
|
|
|
|
|
#2 |
|
Join Date: May 2002
Posts: 5
|
I would suggest that you buy a book.
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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.
|
|
|
|
|
|
#4 |
|
Join Date: May 2002
Posts: 5
|
Well, **** you. I was trying to be helpful.
|
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
|
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! |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Here are several examples...
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
Also, thanks to you, TSTom, Seems I have several choices to choose from now. You guys are a great help.
|
|
|
|
|
|
#9 |
|
MrExcel MVP
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,387
|
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.
|
|
|
|
|
|
#10 | |
|
Join Date: May 2002
Posts: 5
|
Quote:
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? |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|