Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 432
  • Last Modified:

Message box usages

I am looking to use message boxes more with the msgbox function, does anyone have any good samples or guidelines for this, for now just simples Yes, No, Cancel functions would be good, thanks
  • 3
  • 3
1 Solution
If you have designer installed, in the designer help, look for "MessageBox function and statement" topic.
From designer help:
Example 1
' Display the message "Do you want to continue?"
' in a message box labeled "Continue?" and containing
' Yes and No buttons. Assign the return value from
' the MessageBox function to the variable answer.
%Include "lsconst.lss"
Dim boxType As Long, answer As Integer
answer% = MessageBox("Do you want to continue?", boxType&, _
Example 2
' Use the MessageBox statement to display a
' multiline message in a message box labeled "Demo"
' and containing an OK button.
%Include "lsconst.lss"
Dim twoLiner As String
twoLiner = |This message
is on two lines|
MessageBox twoLiner, MB_OK, "Demo"
Here's a simple example using MB_YESNOCANCEL.  Be sure to add the following line to the Options module so that the constants will be recognized by the compiler.

%INCLUDE "lsconst.lss"
	Select Case Msgbox("Click a button:", MB_YESNOCANCEL + MB_ICONQUESTION, "Title")
	Case IDYES: Msgbox("you clicked Yes")
	Case IDNO: Msgbox("you clicked No")
	Case IDCANCEL: Msgbox("you clicked Cancel")
	End Select

Open in new window

jareddraperAuthor Commented:
OK Thanks, so inc which options module do I need to include the Iconst.lss  ?
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

For each LotusScript hotspot (action, button, etc) there is only one Options module.  At a minimum, you should see the following modules in any clickable-control:  Options, Declarations, Click, Initialize, Terminate.  Select the Options module, and paste the next line in:

%INCLUDE "lsconst.lss"

Then, paste your own code in the Click module.
jareddraperAuthor Commented:
Yeah that's what I thought, but when I try to put that in my options module I get this error

test: (Options); 1 : PUBLIC is not allowed in this module

test is the name of my button
OK, sorry, my bad.

The error you are getting is correct because lsconst.lss declares the constants as Public, but you can't declare anything as Public in a button (since no other objects have visibility into the button).  You can still use the include statement, but you have to put it in a Public module that your button has access to.  For example, in a form, you would place it in the (Globals) Options module.

You have 3 options.

1) Start using LotusScript libraries.  Once you have code in a library, you can use it anywhere regardless of whether the library includes Public objects.  I would recommend creating a simple LotusScript library that has your reusable code as well as this include statement.  Then, just add a Use statement in the (Globals) Options module of the form (or view, page, etc) that contains your button.

2) Paste the include statement directly in the (Globals) Options module of the button's parent (ie: view, form, page).  Since the button is contained by the form (or view, page, etc), it has access to anything in the (Globals) section.

3) Don't use the constants.  The integer values of these constants are listed in the help file.  You can achieve the same results by using the integers instead of the constants, but your code will be harder to read.
jareddraperAuthor Commented:
Ok sounds good thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now