I have tried over and over to put together a working Message box
Dim Prompt As String, Tilte As String, Status As String, Status2 As String Dim Buttons As Integer Prompt = "Welcome to Learning 5" Title = "Unload File Check" Status = "Was Unloaded" Status2 = "File NOT Unloaded" Buttons = vbOKOnly + vbCancel MsgBox (Prompt)
I got this far, the Prompt shows the "Welcome to Learning 5"
Every time I tried adding second line of text with the & vbCrLf & Status got an error, I tried the "Status", I tried [Status]
If I just did (prompt + Status it worked but a mess, wanted two lines, plus I wanted the vbYesNoCancel buttons to pop-Up and I wanted a Title for the box
Anyway I called myself searching various ways
MsgBox Examples, Examples of MsgBox Function. Found a lot on Excel on-line but could not seem to make a working one for a starting point.
Jan gave me an example of Macro using variable and I was able to follow the working format on that. I keep looking for a working example
to learn from. Someone please help? No Will someone help me
This also was a failure MsgBox "Test Message Wanted" & CStr(This), vbOKOnly, + CrLf "Check"
ood morning I apologize for my poor English if he can help thisMsgBox "Aggiornate " & vbNewLine & cont & " crocette " & vbNewLine & contaquo & " quote " & vbNewLine & contaprof & " profondita " & vbNewLine & "Tag non corretti " & contsaltati, 0, "Correzione "
MsgBox "Aggiornate " & vbNewLine & cont & " crocette " & vbNewLine & contaquo & " quote " & vbNewLine & contaprof & " profondita " & vbNewLine & "Tag non corretti " & contsaltati, 0, "Correzione "
Richard Phillips said:I have tried over and over to put together a working Message box
I have mentioned before that VBA is provided with many applications apart from MicroStation. The Microsoft Office suite of applications, for example. Many people have written VBA for Excel. Furthermore, they have documented their experience both in books and on the Internet. You can refer to Excel VBA when asking about a common feature such as a message box (VBA MsgBox): it works the same in MicroStation as it does in Excel.
For example, these web pages document the VBA MsgBox with examples.
Regards, Jon Summers LA Solutions
Hi Richard,
I Guess your Problem is the Word "Prompt", because it is a VBA Keyword, and so it is not allowed as variable name. That's why I use Pretext Notation.
Sub DialogTest() Dim sPrompt As String, sTilte As String, sStatus As String, sStatus2 As String Dim nButtons As Integer sPrompt = "Welcome to Learning 5" sTitle = "Unload File Check" sStatus = "Was Unloaded" sStatus2 = "File NOT Unloaded" nButtons = vbOKOnly + vbCancel myPromt = sPrompt & vbNewLine & sStatus Dim myResult As VbMsgBoxResult myResult = MsgBox(myPromt, vbOKCancel, sTitle) End Sub
Mit freundlichen Grüßen / Best regards Volker Hüfner
| AB_DATE Engineering Software | ab-date.de |
So Appreciate, I thought when it said Prompt that was what I was supposed to do, Like the pretext idea. Thank you
Version: MicroStation V8i SS 10
RJB Phillips III (Richard) Praise the Lord for His Mercy and grace in Christ Jesus
I also thank you and I got a number of what I tried from Excel examples. I still seem to struggle with the & name, or the + vb??? + vb??? I am a good copier, I I can find something that does anything close. I can copy and modify, but I never seem to get the ( or , or & correct. Get many errors saying expected = ?? . I will keep trying. I got spoiled on a Macro Jan wrote out an entire working one and off I went and can do a lot all because I got the correct format. I even went to your business page to see If I could find something to latch on. I am moving toward the YesNoCancel feature and the If then elseif of else with the correct boxes and messages. I try suggestions and appreciate them.
Volker Hufner, Thanks to you and all who responded
Question from your example:
Sub DialogTest() '080619 This worked' via reply from MicroStation Reply Dim sPrompt As String, sTilte As String, sStatus As String, sStatus2 As String Dim nButtons As Integer
sPrompt = "Welcome to Learning 5" sTitle = "Unload File Check" sStatus = "Was Unloaded" sStatus2 = "File NOT Unloaded" nButtons = vbOKOnly + vbCancel myPromt = sPrompt & vbNewLine & sStatus & vbNewLine & sStatus2 Dim myResult As VbMsgBoxResult ' forms the 'myResult = MsgBox(myPromt, vbOKCancel, sTitle) myResult = MsgBox(myPromt, nButtons, sTitle) End Sub
I saw your nButtons so I commented out the working myResult and copied it back using
the nbuttons, but when you run that it gives
all fine but I was expecting
the vbOKonly + vbCancel, did not know what happened? I also plan to try to add +vbdefaultButton2 which should move it to Retry
where I am trying to learn and save working examples. I was trying the abCrLf I think
well 3:23am my time, got to get some rest so thank yo and Jon (as always) and now
I read this information:
VbMsgBoxResult Value Button SelectedvbOK 1 OK ------------------------------ give a 1 when pressedvbCancel 2 Cancel ------------------------------ give a 2 when pressedvbAbort 3 Abort ------------------------------ give a 3 when pressedvbRetry 4 Retry ------------------------------ give a 4 when pressedvbIgnore 5 Ignore ------------------------------ give a 5 when pressedvbYes 6 Yes ------------------------------ give a 6 when pressedvbNo 7 No ------------------------------ give a 7 when pressed
can you get something back from MsgBox to show or use the values ? Only wondering
I did no see any on Critical, ok gotta go, thank you again.
you are mixing up results and definitions. I could only mark out Jon Summers. You need to learn some fundamental basics. You can't learn "how to drive a car" by watching and copying Michael Knight in knight-rider on TV :-) Some lessons by a qualified instructor will save you month of frustration!
As Jon and Volker mention it is best to abstract, learn and differentiate between "common Microsoft VBA programming" vs. "MicroStation VBA programming" and leverage each company's respective documentation, communities, and forums; for best results.
Here are a few places that may help get started with Microsoft Office VBA (same engine used in MicroStation VBA - just extended with our Object Model).
Lastly, YouTube provides a number of very good (though not all so good) Microsoft VBA Getting Started videos. In particular, I (just my opinion) found this series to provide a very nice and helpful pace and topics covered consider when getting starting: Leila Gharani's: Excel VBA and Macros Tutorials.
Given the above locations, things like MsgBox constants and VBA Keywords (reserved for VBA names not to use as your own variables) will be more clear going forward.
Good luck and HTH,Bob