Bug 146282 - msgBox only displays "OK" button
Summary: msgBox only displays "OK" button
Status: RESOLVED INVALID
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.0.6.2 release
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-17 18:04 UTC by Aaron Gerber
Modified: 2022-02-02 17:54 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Gerber 2021-12-17 18:04:54 UTC
Description:
My macro:

```
Sub Message_Box_Test
	dim iResponse as Integer
	dim strNotes as String

	iResponse = MsgBox("Are there special notes that need to be added to this report?", Buttons = YESNOCANCEL, "Special Notes")
	If iResponse = 7 Then
		MsgBox "No"
	ELSEIF iResponse = 2 Then
		Exit Sub
	ELSE
		strNotes = inputBox("Enter the special notes as they should appear:", "Special Notes")
	END IF
	
	msgBox strNotes


End Sub```

When I run it, the first message box has the correct title, but only an OK button.


Steps to Reproduce:
1.Run the macro in the description (between the ```'s).

Actual Results:
The first message box has only one button

Expected Results:
It should have three buttons, yes, no, and cancel


Reproducible: Always


User Profile Reset: No



Additional Info:
Version 7.0.6.2(x64)
Build 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
4 threads
VCL:win
en-US
Calc: threaded
I'm somewhat annoyed that I couldn't highlight the information in the About window to copy and paste here.
Comment 1 himajin100000 2021-12-17 19:20:46 UTC
I believe this report should be marked NOTABUG or INVALID.

Correct code would be like the following.
===========================


Option Explicit
Option VBASupport 1 ' without this line vbYesNoCancel is not defined.

Sub Message_Box_Test
	dim iResponse as Integer
	dim strNotes as String

    ' Correct Enum member would be vbYesNoCancel, not YESNOCANCEL
    ' Also, I added colon to indicate named parameter.
	iResponse = MsgBox("Are there special notes that need to be added to this report?", Buttons:= vbYesNoCancel, "Special Notes")
	If iResponse = 7 Then
		MsgBox "No"
	ELSEIF iResponse = 2 Then
		Exit Sub
	ELSE
		strNotes = inputBox("Enter the special notes as they should appear:", "Special Notes")
	END IF
	
	msgBox strNotes
End Sub
Comment 2 Leslie 2021-12-18 01:02:44 UTC
"I'm somewhat annoyed that I couldn't highlight the information in the About window to copy and paste here"   

Additionally, there is a button on the About window that copies the information needed to the clipboard.
Comment 3 Julien Nabet 2021-12-18 12:59:34 UTC
Reading this https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03010102.html
you should rather use:
iResponse = MsgBox("Are there special notes that need to be added to this report?", MB_YESNOCANCEL, "Special Notes")
Could you give it a try?

BTW, there's an error in the documentation, it's not MB_ABORTRETRYCANCEL but MB_ABORTRETRYIGNORE
Comment 4 himajin100000 2021-12-18 13:42:32 UTC
1. Honestly Speaking, I still haven't found the mechanism with which our Runtime makes the enum members in ooo.vba.VbMsgBoxStyle.

2. Secondly, though we can access MB_YESNOCANCEL IN STARBASIC
https://opengrok.libreoffice.org/xref/core/basic/source/runtime/stdobj.cxx?r=0d563373#584

but not in MS-VBA because the constant comes from winuser.h, which is for C++, not for MS-VBA.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox
Comment 5 Julien Nabet 2021-12-18 14:08:20 UTC
Olivier: I put you in cc of the other bugtracker but since I created another bugtracker for the doc part, don't hesitate to uncc yourself.

Mike: thought you might have some opinion here.
Comment 6 Mike Kaganski 2021-12-18 15:32:01 UTC
(In reply to Julien Nabet from comment #5)
> Mike: thought you might have some opinion here.

I'm sorry, I don't quite see on which question my opinion is needed.

There's a user error of using non-declared/defined variable YESNOCANCEL, which evaluates to 0 when used without Option Explicit.

There's a (unrelated) wrong entry in help, already fixed by you in bug 146299 :)

There's some misunderstanding mentioned in comment 4, but I don't quite see what is wanted there.

There's also a bug (IMO) related to enums not fully supported in Option Compatible - see bug 145753 comment 3. But that is outside of scope of this.
Comment 7 Julien Nabet 2021-12-18 16:16:34 UTC
(In reply to Mike Kaganski from comment #6)
> (In reply to Julien Nabet from comment #5)
> > Mike: thought you might have some opinion here.
> 
> I'm sorry, I don't quite see on which question my opinion is needed.
> 
> There's a user error of using non-declared/defined variable YESNOCANCEL,
> which evaluates to 0 when used without Option Explicit.
> 
> There's a (unrelated) wrong entry in help, already fixed by you in bug
> 146299 :)
> 
> There's some misunderstanding mentioned in comment 4, but I don't quite see
> what is wanted there.
> 
> There's also a bug (IMO) related to enums not fully supported in Option
> Compatible - see bug 145753 comment 3. But that is outside of scope of this.
Ok I hadn't read comment 1 from Himajin100000.

So there are 2 ways to provide the option:
- MB_ABORTRETRYIGNORE when no VBASupport or VBASupport = 0
- Buttons:= vbYesNoCancel when VBASupport = 1

About the comment 3, I don't know.

Sorry for the noise then.