DataMatrixEncode SDK и Visual Basic

Задают много вопросов, как использовать DataMatrixEncode SDK в приложениях Visual Basic, но ведь это вопрос правильности понимания вызовов функций _stdcall C Dll из других языков. Но все же ниже приведен пример, как генерировать код, используя VisualBasic.
Module Module1

    Private Declare Function EncodeDataMatrix Lib "DataMatrixEncode.dll" _
                (ByVal EncodeText As String, ByVal EncodeSize As Integer, _
                 ByRef out_bitmap As Byte, ByRef buffer_size As Integer, _
                 ByVal SizeCell As Integer, ByVal Code As Integer, _
                 ByVal Mode As Integer, ByVal SizeNum As Integer) As Integer

    Sub Main()
        Dim buffer As String
        Dim out_bitmap() As Byte
        Dim s As Integer
        Dim result As Integer
        s = 1000000 
        buffer = "Hello World"
        out_bitmap = New Byte(s) {}
        Dim s1 As IntPtr = New IntPtr(s)
        result = EncodeDataMatrix(buffer, Len(buffer), out_bitmap(0), s1, 4, 0, 5, 0)

        If result = 0 Then
            Dim f As Integer
            Dim i As Integer
            f = FreeFile()
            FileOpen(f, "out.bmp", OpenMode.Binary, OpenAccess.Write)
            For i = 0 To s1
                FilePut(f, out_bitmap(i), i + 1)
            Next i
            FileClose(f)            
        End If
    End Sub

End Module