Page 1 of 2

MsgBox question

PostPosted: Thu Sep 01, 2011 4:16 pm
by GaryVass
I have a MsgBox requestor (below) that I can't get to work... it does work in kbasic....

response = MsgBox("No security found in Master Security List with a ticker of " & TTICK & " Would you like to add it now?", kbYesNo, "Should We Add This Asset to the List?")

With the above line I get a 'parser or syntax error' If I change the kbYesNo to vbYesNo I get a 'types incompatible error' response is dimmed as Integer. I have also tried Boolean to see if there were any differences (none).

What do I need to change?

Thanks in advance.

Re: MsgBox question

PostPosted: Thu Sep 01, 2011 5:29 pm
by Slowdown
pulled from the examples and changed a bit,

Code: Select all
Sub ShowMsgBox()
  Dim ReturnValue As Integer

  ReturnValue = MessageBox(MessageBox.Warning, "This is a Warning", "My warning text", "informative text", "details and more...", MessageBox.Apply, List("VB_Yes", MessageBox.AcceptRole), List("VB_No", MessageBox.RejectRole))

  Print "When Accepted : " & MessageBox.AcceptRole & "\n"
  Print "When Applied  : " & MessageBox.Apply & "\n"
  Print "When rejected : " & MessageBox.RejectRole & "\n"
  Print "Returned by MessageBox : " & ReturnValue
End Sub

Re: MsgBox question

PostPosted: Thu Sep 01, 2011 5:57 pm
by GaryVass
Thanks... I did not see those in the examples.... I guess you have to spell out messagebox as opposed to just the MsgBox that works for just simple messages.

Re: MsgBox question

PostPosted: Fri Sep 02, 2011 7:06 am
by berndnoetscher
It works, but change:

kbYesNo must be vbYesNo

Re: MsgBox question

PostPosted: Fri Sep 02, 2011 10:41 am
by Slowdown
Sorry to report but,
Code: Select all
Dim ReturnValue As Integer

ReturnValue = MsgBox("some text", vbYesNo, "some more text")

Raises an error types incompatible.
edit;

It will work but not as showed.
This will work,
Code: Select all
Dim ReturnValue As List
ReturnValue.Append(MsgBox("some text", vbYesNo, "some more text"))
MsgBox(ReturnValue.Object(0))

Seems the function returns not an Integer but an Array :roll:

Re: MsgBox question

PostPosted: Fri Sep 02, 2011 1:07 pm
by Henning
Hi,

What comes to mind is that MsgBox should, in this case, return the Value of the Constant for either vbYes or vbNo.
So one couls code:

If MsgBox("tatata", vbYesNo, "dididi") = vbYes Then
....
Else
....
End If

/Henning

Re: MsgBox question

PostPosted: Fri Sep 02, 2011 3:51 pm
by Slowdown
sorry Henning, no go same error.

Re: MsgBox question

PostPosted: Fri Sep 02, 2011 4:39 pm
by Henning
Hi,

Not a valid program code, just a hint on how it, in my mind, is supposed to work. ;)

/Henning

Re: MsgBox question

PostPosted: Sat Sep 03, 2011 2:51 pm
by GaryVass
Thanks Slowdown,

I used your answer to get a working set of code, as a list, of course, but it works or at least compiles so far.

Re: MsgBox question

PostPosted: Sun Sep 04, 2011 6:50 am
by Slowdown
Be carefull,
If it's a bug and when repaired you will end up again with a none working code.
I don't know if my code is correct, it works but that is all. ;)