I\'m very new to programming and I\'m just starting to learn VBA with excel. I came across on this website and did the examples here but I have question about this code:
<
When I first started with MsgBox
answers, I almost always declared the answer as an Integer
. However, I learned that the best thing to do is to declare your message
variable as VbMsgBoxResult
, which is an enumeration that will always show the available answers. In the picture below, the IDE (e.g. the Visual Basic for Application editor) will show you the possible options available in VbMsgBoxResult
.
You could store your answer
variable as an Integer
since all of the variables in the Enumeration (e.g. vbAbort
, vbYes
, vbOK
, etc.) do in fact resolve to integers. However, you have to figure out what the integer values for those variables are every time you want to reference them. In my opinion, it's a better practice to store your answer as VbMsgBoxResult
so you can actually see the available answers.