Calling Visual Basic DLLs from R20/12/2004
I want to test a series of growth models that are part of a DLL(Dynamic Link Library) written in Visual Basic. Although I could write several pieces of code in VB to test the library, check I will try to access it from R. In this way I can run simulations and then process the results from within a statistical package.
I obtained the RDCOM client and the SWinTypeLibs facilities from the Omega Hat Project for Statistical Computing. If you are running R 2.0 you should get the latest compilations from here (RDCOMClient_0.8-1.zip, view 11-Oct-2004, 12:08, 433K and SWinTypeLibs_0.2-1.zip, 11-Oct-2004, 12:09, 147K).
It is possible to learn about the classes, methods, parameters and return types of a COM server using the SWinTypeLibs library. Once we have learn about the server, we can access it using the RDCOMClient (this is explained in this presentation in PDF format, 50KB). For example:
library(RDCOMClient) ie = COMCreate("InternetExplorer.application") ie[["Visible"]] <- TRUE\ ie$Navigate2("http://www.uncronopio.org/quantum/")
will load the library, connect to Internet Explorer, display the window and point the browser to Quantum Forest. An example using Excel would be:
exc <- COMCreate("Excel.Application") exc[["Visible"]] <- TRUE\ books <- exc[["Workbooks"]] books$Add() actsheet <- books[][["ActiveSheet"]] myrange <- actsheet$Range("A1:C10") myrange[["Value"]] <- asCOMArray(matrix(rnorm(30, 10, 3)))
This will connect to Excel, show the program, get a list of workbooks, add one, get which sheet is active, define a range and fill it with N(0,1) random numbers.
I continue exploring the package to see if I can connect to my own DLL.Filed in programming, software, statistics