18.01.2013 Views

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

LotusScript for Visual Basic Programmers - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

developer). The objects also contain code, which is used to manipulate or<br />

inspect this data at run time.<br />

A very simple example might be to create a class to display a message.<br />

We’ll do this in <strong>LotusScript</strong> by creating a class called DisplayMsg. In the<br />

following listing, the DisplayMsg class is shown, where you will see a<br />

property called Text and a method called Display.<br />

Class DisplayMsg<br />

' Declare member variables in a <strong>LotusScript</strong> class<br />

mMsg As String<br />

mMsgNumber As Integer<br />

Public Property Set Text As String<br />

mMsg = Text<br />

End Property<br />

Public Sub Display<br />

Msgbox(mMsg)<br />

End Sub<br />

End Class<br />

The text <strong>for</strong> the class is entered into the declarations of a Notes <strong>for</strong>m. The<br />

code in the next listing is entered into the Sub Click event of a button on<br />

this Notes <strong>for</strong>m. Here you will see a variable created as a variant called<br />

objMsg, which will be used to hold the instance of our message object. The<br />

set objMsg = New DisplayMsg line actually creates the instance of the<br />

object and loads a reference of it into the objMsg variable.<br />

Sub Click (Source As Button)<br />

Dim objMsg as Variant<br />

Set objMsg = New DisplayMsg<br />

objMsg.Text = "(" & Format$(68) & ") - " & Error$(68)<br />

objMsg.Display<br />

Delete objMsg<br />

End Sub<br />

20 <strong>LotusScript</strong> <strong>for</strong> <strong>Visual</strong> <strong>Basic</strong> <strong>Programmers</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!