How to automate Rumba through VB.Net

Dear members of the forum,

Earlier I was trying to automate Rumba through Excel VBA and now it has been decided to use VB.Net for the same.

Has anyone automated Rumba through VB.Net before? I'm using MicroFocus Rumba Desktop 9.4.1.

I tried the following code to open mainframe application but it throws "ActiveX component Can't create object" error. I faced this same error when I tried through Excel VBA.


Dim oSys As Object

oSys = CreateObject("rumba.system") 


(instead of Rumba.System, I've also tried "Microfocus.Rumba" and "Rumba.Application")

This is the first time I'm trying with Rumba.

Any guidance is deeply appreciated.


  • Hi Gowrisankar,
    there several approaches for automating your Host access with RUMBA

    1. VBA-Addon for RUMBA (RUMBA 9.5 and later)
    With the VBA-Addon for RUMBA you can automate RUMBA from third party Applications without the need to embed the RUMBA Control.

    Code snippet:
    Sub Main()
    Dim app As RumbaApplicationObject
    Dim session As RumbaEmulationSessionObject
    Dim status As BooleanSet app = GetObject("", "MicroFocus.Rumba")
    Set session = app.GetSessionByName("Mainframe Display")

    status = session.Connected

    If (status = False) Then

    ElseIf (status = True) Then
    MsgBox ("Rumba is connected")
    End If
    End Sub

    2. The ActiveX approach ( Any Rumba version)
    You can embed the RUMBA control in your Application e.g in Excel 32bit and start the automation
    Code snippet: (Excel VBA)

    Set wrkSheet = Worksheets(1)
    Set MFDsp = MFForm.Dsp1

    MFForm.Dsp1.HostInterface.Name = "WallData.TN3270Link"
    MFForm.Dsp1.HostInterface.Interface.InsertName2 "your Host IP"
    MFForm.Dsp1.HostInterface.StartupModelType = 2

    lRC = MFForm.Dsp1.RDE_Connect_Hsynch(True, 2, 10000, "", 0, 0)

    3. RDE.NET (Rumba 8.x and newer)
    Open Visual Studio IDE
    Create a new C# Windows Forms Application by choosing File > New > Project > Other Languages > Visual C# > Windows Forms Application.
    Open the Visual Studio Toolbox tab.
    From the Micro Focus RDE group, drag and drop MFDisplayControl into the form. You can adjust its size if you want.
    Important: In the Solution Explorer window two new references are automatically added to your project, MFDisplay.Control and Microfocus.RDE.Framework.
    These are the RDE. NET references, so do not delete them. Add a button to the form from the tool box, for example:

    Double-click on the button and add the following code into the button1_Click method:
    private void button1_Click(object sender, EventArgs e)
    Run the application and click button1. You will be connected to Mainframe Demo Host.

    Emulator High Level Language API (EHLLAPI): This interface provides
    functions to access emulator "presentation space" data such as characters on the
    host screen. It also provides functions for sending keystrokes to the host,
    intercepting user-entered keystrokes, querying the status of the host session,
    uploading and downloading files, and other functions.
    Declare Function hllapi Lib "E:\Micro Focus\RUMBA\System\ehlapi32.Dll" (Func As integer, ByVal Buffer as String, bSize as Integer, RetC as Integer) As Long
    Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As Long
    Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

    Sub Main()
    Dim Astr As String
    Dim Alen As Integer
    Dim RetC as Integer
    Dim Func As Integer


    Func = 10
    AStr = Space(48)
    ALen = 48
    hllapi Func, Astr, Alen, RetC

    Msgbox "The following sessions are open: " & Chr$(10) & Mid$(Astr, 1, 1) & Chr$(10) _
    & Mid$(Astr, 13, 1) _
    & Chr$(10) & Mid$(Astr, 25, 1) _

    'Connect PS
    Func = 1 ' connect PS
    Astr = "C"
    Alen = Len(Astr)
    hllapi Func, Astr, Alen, RetC
    Msgbox RetC & Chr$(10) & Mid$(Astr, 37, 1)

    Func = 2 ' disconnect PS
    Astr = ""
    Alen = Len(Astr)
    hllapi Func, Astr, Alen, RetC
    End Sub

    5. RUMBA Scripts / Macro (any version)
    RUMBA provides a powerful Macro and Scripting Engine
    It allows you to write scripts that interact with the host and the local environment, such as data from a spreadsheet, text file, database, etc.
    Many of the command require that a profile be set up in advance of using the command
    You can find different code samples in you RUMBA installation when you install ScriptEngine.msp.


    Hope this helps you to get a general overview about your options.


  • Hi andree,

    Thank you for your response.

    I can't use the Add-on because I'm using 9.4.1 version which is provided by customer.

    I'm now trying option 4 which you shared. (EHLLAPI or WinHLLAPI).

    I was able to replicate your code and managed to include a HA_SENDKEY function (3rd in the sequence).

    Can you please provide any examples or documentation for using other important functions like opening a desired session, getting text from mainframe, setting cursor position, passing function keys, etc.,

    I'm looking for examples but not found anything useful so far.


  • Hi andree,

    Thanks for your response.

    For some reasons, I can't use any other options and I have to focus on only using VB.Net to control Rumba mainframe. 

    I couldn't add ehlapi32.dll or WHLLAPI.dll as references to the .Net solution.

    I couldn't create objects of "Microfocus.Rumba", etc., because of the error "Cannot create Activex component"

    I tried to resolve it by registering the dll using RegAsm.exe. But it says the Dll is not valid .net assembly.

    I have attached error snapshots.

    I'm stuck with no further options. Can you please share your thoughts on this ?



  • Hi andree,

    Now I'm trying your option 4 as you gave below since I found that these DLLs can't be added as references. 

    "Declare Function hllapi Lib "E:\Micro Focus\RUMBA\System\ehlapi32.Dll" (Func As integer, ByVal Buffer as String, bSize as Integer, RetC as Integer) As Long
    Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As Long
    Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)"

    It works great in an Excel macro but I want to make this work in VB.Net. 

    I included "Connect to PS" function and "Send Key" function in VB.Net. I'm getting a return code of 2 for both functions. What is strange is that, there is no explanation for Return code of 2 for "Connect to PS" in the EHLLAPI guide. 
  • Please contact Micro Focus Supportline for further assistance with this request.