Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Calc BASIC | How to call Function in other Library ?

'Library1
'Module1
Option Explicit
Sub TestConnectingEmbeddedFirebird1
    Dim iBox%
    iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
    If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
        On Local Error GoTo CloseConn
        Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
        MsgBox "Embedded Firebird database connected"
        DisconnectDatabase(db)
        MsgBox "Embedded Firebird database disconnected"
    Else
        MsgBox "No embedded Firebird database connected"    
    End IF
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub


'Library2
'Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebied database) ?

Calc BASIC | How to call Function in other Library ?

'Library1 'Module1 Option Explicit Sub TestConnectingEmbeddedFirebird1 Dim iBox% iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then On Local Error GoTo CloseConn Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0") MsgBox "Embedded Firebird database connected" DisconnectDatabase(db) MsgBox "Embedded Firebird database disconnected" Else MsgBox "No embedded Firebird database connected"
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub


'Library2
'Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebied database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 'Module1 Option Explicit Sub TestConnectingEmbeddedFirebird1 Dim iBox% iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then On Local Error GoTo CloseConn Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0") MsgBox "Embedded Firebird database connected" DisconnectDatabase(db) MsgBox "Embedded Firebird database disconnected" Else MsgBox "No embedded Firebird database connected"
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub


'Library2
'Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebied Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 'Module1 Option Explicit Sub TestConnectingEmbeddedFirebird1 Dim iBox% iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then On Local Error GoTo CloseConn Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0") MsgBox "Embedded Firebird database connected" DisconnectDatabase(db) MsgBox "Embedded Firebird database disconnected" Else MsgBox "No embedded Firebird database connected"
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub


'Library2
'Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 'Module1 'Library1 Module1

Option Explicit
 Sub TestConnectingEmbeddedFirebird1
     Dim iBox%
     iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
     If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
         On Local Error GoTo CloseConn
         Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
         MsgBox "Embedded Firebird database connected"
         DisconnectDatabase(db)
         MsgBox "Embedded Firebird database disconnected"
     Else
         MsgBox "No embedded Firebird database connected" 
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub

Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub


'Library2
'Module1


'Library2 Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 Module1

Option Explicit
Sub TestConnectingEmbeddedFirebird1
    Dim iBox%
    iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
    If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
        On Local Error GoTo CloseConn
        Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
        MsgBox "Embedded Firebird database connected"
        DisconnectDatabase(db)
        MsgBox "Embedded Firebird database disconnected"
    Else
        MsgBox "No embedded Firebird database connected"    
    End IF
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub




'Library2 Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 Module1

 Option Explicit
Sub TestConnectingEmbeddedFirebird1
    Dim iBox%
    iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
    If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
        On Local Error GoTo CloseConn
        Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
        MsgBox "Embedded Firebird database connected"
        DisconnectDatabase(db)
        MsgBox "Embedded Firebird database disconnected"
    Else
        MsgBox "No embedded Firebird database connected"    
    End IF
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub




'Library2 Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 Module1

 Option Explicit
Sub TestConnectingEmbeddedFirebird1
    Dim iBox%
    iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
    If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
        On Local Error GoTo CloseConn
        Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
        MsgBox "Embedded Firebird database connected"
        DisconnectDatabase(db)
        MsgBox "Embedded Firebird database disconnected"
    Else
        MsgBox "No embedded Firebird database connected"    
    End IF
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub




'Library2 Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

'Library1 Module1

Module1
    Option Explicit
 Sub TestConnectingEmbeddedFirebird1
     Dim iBox%
     iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
     If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
         On Local Error GoTo CloseConn
         Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
         MsgBox "Embedded Firebird database connected"
         DisconnectDatabase(db)
         MsgBox "Embedded Firebird database disconnected"
     Else
         MsgBox "No embedded Firebird database connected"  
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub




'Library2 Module1

Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

Code

'Library1 Module1
 Option Explicit
 Sub TestConnectingEmbeddedFirebird1
     Dim iBox%
     iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
     If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
         On Local Error GoTo CloseConn
         Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
         MsgBox "Embedded Firebird database connected"
         DisconnectDatabase(db)
         MsgBox "Embedded Firebird database disconnected"
     Else
         MsgBox "No embedded Firebird database connected" 
End IF Exit Sub CloseConn: MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")" DisconnectDatabase(db) End Sub

Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

 'Library2 Module1
 Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods

Calc BASIC | How to call Function in other Library ?

Code

'Library1 Module1
Module1'
Option Explicit
Sub TestConnectingEmbeddedFirebird1
    Dim iBox%
    iBox = MB_YESNO + MB_DEFBUTTON2 + MB_ICONQUESTION
    If MsgBox ("Do you want to connect embedded Firebird database ?", iBox) = IDYES Then
        On Local Error GoTo CloseConn
        Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
        MsgBox "Embedded Firebird database connected"
        DisconnectDatabase(db)
        MsgBox "Embedded Firebird database disconnected"
    Else
        MsgBox "No embedded Firebird database connected"    
    End IF
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

Sub TestConnectingEmbeddedFirebird2
    On Local Error GoTo CloseConn
    Dim db As Object : db = Library2.Module1.ConnectDatabase("firebird0")
    DisconnectDatabase(db)
    Exit Sub
CloseConn:
    MsgBox "Error " & Err & ": " & Error$ & " (line : " & Erl & ")"
    DisconnectDatabase(db)
End Sub

'Library2 Module1
Module1'
Option Explicit
Function ConnectDatabase(dbFilename$) As Object
    Dim dbContext   As Object   : dbContext     = createUNOService("com.sun.star.sdb.DatabaseContext")
    Dim oDataSource As Object   : oDataSource   = dbContext.GetByName(dbFilename)
    ConnectDatabase = oDataSource.GetConnection("","")'("Username","Password")
End Function

Sub TestConnectingEmbeddedFirebird1 or Sub TestConnectingEmbeddedFirebird2 sent the error message:

image description

image description

image description

image description

How can we call Function in other Library (and in order to connect embedded Firebird database) ?

C:\fakepath\0002.ods