○VB6のクラスをVBAにて使用する

■VB6 DLLにて作成されたActiveXコントロール

プロジェクト名	:	aProject
クラス名		:	Class1

Public Function addInteger(a As Integer, b As Integer) As Integer
    addInteger = a + b
End Function
Public Function addLong(a As Long, b As Long) As Long
    addLong = a + b
End Function
Public Function addDouble(a As Double, b As Double) As Double
    addDouble = a + b
End Function
Public Function addString(a As String, b As String) As String
    addString = a + b + ":てすと"
End Function


■VBAでの呼び出し
ActiveXコントロールを参照設定にて参照します

Public obj As New aProject.Class1

Public Function test()
    
    Dim i As Integer
    i = obj.addInteger(10, 20)
    
    Dim l As Long
    l = obj.addLong(20, 30)
    
    Dim d As Double
    d = obj.addDouble(0.01, 1.1)
    
    Dim s As String
    s = obj.addString("いなば", "test")
    
End Function



▲トップページ > Visual BASIC と C#