例: CreateDatabase method

次の Visual Basic コードは、データベースがなければ新規に作成します。

Private Sub CreateDatabase_Click()
On Error GoTo errorHandler
Dim s As New NotesSession
s.Initialize
Dim dir As NotesDbDirectory
Dim db As NotesDatabase
Set dir = s.GetDbDirectory("")
Set db = dir.CreateDatabase("quack.nsf", True)
db.Title = "Ducks of North America"
MsgBox "Created database quack.nsf", , "Created database"
Exit Sub
errorHandler:
If Err.Number = NOTES_ERRORS.ERR_NOTES_ERROR2 Then
  MsgBox "Database quack.nsf already exists", , "Exists"
Else
  MsgBox Err.Description, , "Error " & Right(Hex(Err.Number), 4)
End If
End Sub