hello,
is it possible to use the MsgBox function like in Vb6:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])
With Xojo i use only msgbox(“message”), but not possible msgbox(“message”,buttons,title).
hello,
is it possible to use the MsgBox function like in Vb6:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])
With Xojo i use only msgbox(“message”), but not possible msgbox(“message”,buttons,title).
[quote=99557:@Djamel AIT AMRANE]hello,
is it possible to use the MsgBox function like in Vb6:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])
With Xojo i use only msgbox(“message”), but not possible msgbox(“message”,buttons,title).[/quote]
Use MessageDialog :
http://documentation.xojo.com/index.php/MessageDialog
Yes, it is possibe. Here are the details.
Although discouraged by Xojo, I prefer the MsgBox for user dialogs. Simple and convenient.
Why is the good old MsgBox discouraged by Xojo???
What then, is the Xojo recommended way of presenting a simple message to the user??
Thanks.
AFAIK it is only discouraged for debugging purposes.
MessageDlg is the preferred way of presenting messages to the user…
Alexander - can you explain why?
I am curious as to why something more complex is recommended, when you only want to tell the user something.
Thanks.
There is nothing in the LR to this effect. Seems like the choice between MsgBox and MessageDialog is left open.
Maybe someone from Xojo can weigh on that ?
Come on Norman !
It’s Ok for MessageDialog, thank you Michel.
I tried but nothing, could give an example ?
[quote=99630:@Djamel AIT AMRANE]It’s Ok for MessageDialog, thank you Michel.
I tried but nothing, could give an example ?[/quote]
[code] Dim d As New MessageDialog //declare the MessageDialog object
Dim b As MessageDialogButton //for handling the result
d.icon=MessageDialog.GraphicQuestion //display question icon
d.ActionButton.Caption=“Import”
d.CancelButton.Visible=True
d.Message=“Do you want to import … ?”
d.Explanation=“The database file must be imported into the applications sandbox container.”
b=d.ShowModal //display the dialog
Select Case b //determine which button was pressed.
Case d.ActionButton
Case d.CancelButton
End Select[/code]
I’ve not seen nor read anything which would indicate this is true.
That’s because using a MsgBox to show what is happening in your code can cause other items to refresh and lead to false info about what is really happening.
Roger,
Alexander claimed it was discouraged (not me)
//
// Example from LR
//
Dim n As Integern = MsgBox("Do you want to rebuild this mailbox?", 36)
If n = 6 Then
//user pressed Yes
Else If n = 7 Then
//user pressed No
End If
Actually I only use MsgBox for debugging purposes or put differently, I only use it during development, never in finished code. Thats what the much more powerful MessageDialog class is for, I think.
Dont tell, but I tend to use Magbox more often than none instead of System.DebugLog, because I do not have to look for the message in the messages pane
I never encountered yet the dreaded change in event order warned against by Xojo, but if that happened, I can always go to System.DebugLog…
[quote=99679:@Syed Hassan]
//
// Example from LR
//
Dim n As Integern = MsgBox("Do you want to rebuild this mailbox?", 36)
If n = 6 Then
//user pressed Yes
Else If n = 7 Then
//user pressed No
End If
[/quote]
You had two errors in the code. Should be :
dim n as integer
(not integern)ElseIf
(not Else if)Use msgbox to display the result. Otherwise you never know what the user chose :
Sub Action()
//
// Example from LR
//
Dim n As Integer = MsgBox("Do you want to rebuild this mailbox?", 36)
If n = 6 Then
//user pressed Yes
msgbox "User clicked Yes"
ElseIf n = 7 Then
//user pressed No
msgbox "User clicked No"
End If
End Sub
//
// Example from LR
//
Dim n As Integer = MsgBox("Do you want to rebuild this mailbox?", 36)
If n = 6 Then
//user pressed Yes
Else If n = 7 Then
//user pressed No
End If
Sayed, this code is almost equivalent to Vb6 msgBox, unfortunately we can display only the msg and the icon, nothing else.
FYI - Where Ive seen MsgBox interfere with debugging is event driven code. If a textfield control that has code in its LostFocus even for example, I believe that code will execute if you show a MsgBox.
This type of thing becomes an issue when you have a complex UI with lots of control events. The MsgBox call is making the events fire and the application isnt in the state you’re assuming it to be in.
Heres a little sample app that demonstrates the issue. Notice how the second time the dialog is shown, the value of the property state has changed.
Easy to see whats happening in the sample. Much harder when you have lots of controls, nested containers, etc…