Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to VBA calling APIs Please help!!!!! - thanks

Status
Not open for further replies.

RIDELIGHTNING

IS-IT--Management
Sep 10, 2007
3
US
Hey all,
I really need some help. I've been searching the web for three days straight and I can't find anything to help me along.
What I'm trying to do: I'm using VBA from Access to enter keystrokes in Netmanages Rumba for Mainframes. I'm somewhat successful in doing this with sendkey but I'm having to put in timers to wait for screen transitions. This kind of works but you never really know when Rumba is ready to receive again. So I did the research and found that WHLLAPI can tell me when Rumba is ready.
The problem: I wrote (for the first time) code to call the API functions from WHLLAPI.dll. I'm getting back totally unexpected results so I'm guessing I'm doing something very wrong. Below is API main call and one of it's functions, my code, and result.

extern VOID FAR PASCAL WinHLLAPI( )

LPWORD lpwFunction, /* Function name */
LPBYTE lpbyString, /* String pointer */
LPWORD lpwLength, /* String (data) length */
LPWORD lpwReturnCode ); /* Return code */

here's the function i'm calling

Prerequisite Functions

None.

Function Call

WinHLLAPI(CONNECTPS,lpbyString,lpwLength,lpwReturnnCode)

Call Parameters

Parameter Description
Data String One-character short name session ID of the Host session to connect with, either an upper- or lower-case letter.
Data Length NA (defaults to 1).
PS Position NA
Return Codes

Code Description
WHLLOK Connect request successful and the specified session is unlocked and ready for input.
WHLLNOTCONNECTED Connect request failed, specified short name session ID is invalid.
WHLLPSBUSY Connect request successful, but the specified session is busy.
WHLLINHIBITED Connect request successful, but the specified session is locked (input inhibited).
WHLLSYSERROR Connect request failed due to a system error.
WHLLUNAVAILABLE Connect request failed, specified session is unavailable (already in use).

my code
Code:
Option Compare Database


Private Declare Function WinHLLAPI Lib "C:\Program Files\NetManage\System\WHLLAPI.dll" _
(ByRef Func As Integer, ByVal DataString As String, ByRef Length As Integer, ByRef RetC As Integer) As Long

Sub mytest()
Dim str As String
Dim lng As Integer
lng = 0
str = "X"
HLL 2, str, 1, lng


End Sub
Private Function HLL(Func As Integer, Astr As String, Alen As Integer, RetC As Integer)
Dim str As String
Dim returncode As Long

returncode = WinHLLAPI(Func, Astr, Alen, RetC)
MsgBox ("astr = " & Astr & " alen = " & Alen & " retc = " & RetC)
MsgBox (returncode)

End Function
Now if I have Rumba running or not I get:
In the first msgbox retc = -4093
In the second I get 61443

I confused! Now the documentation has words for the return codes but defines the variable as an integer. How am I supposed to interpret that? When I was at the IBM site looking at EHLLAPI they have integers as return codes but they're like 1 through 10 (maybe up to 100). I must be calling the function wrong.

Any help from you smart people out there would be MOST appreciated!!!
 




Hi,

Don't know Rumba, but have had experience with other mainframe terminal emulators.

Check in the Rumba library for a function that returns a value when the cursor returns.

I use a technique that I

1. Load a value
2. Move AWAY from the load loaction
3. send a keystroke that "enters" a value in the emulator and
4. WAIT for the cursor to return to the REST location in a loop, something like this...
Code:
With oScrn
    .Area(4, 20, 4, 36).Value = sPN
    .MoveRelative 1, 1, 1
    .SendKeys ("<enter>")
    Do Until (.WaitForCursor(4, 20))
        DoEvents
    Loop
End with


Skip,

[glasses] When a group touring the Crest Toothpaste factory got caught in a large cooler, headlines read...
Tooth Company Freeze a Crowd! and
Many are Cold, but Few are Frozen![tongue]
 
Skip,
Thanks so much for replying. See my problem is that I don't have a COM object to reference (that I know of). So I can't use code like yours. I really need to understand what I'm doing wrong with this API. Thanks for taking the time to try and help!
 
hi, I have done a similar thing before but I embeded the rumba window directly into access. This allows u to connect to the mainframe and do all of the processing without having to do sendkeys.

This was a good few yrs back, so I can not remeber exactly how to do it, might be worth lokking into though.
 
The version I have says there isn't a prerequisite function and I couldn't find the function start up. BUT! I looked at "more controls" in Access and the Mainframe display was there just like you said. OMG have I been waisting my time. This is soooo much easier with the embeded object.
I was also found the help file for those objects in
C:\Program Files\NetManage\Mframe\Wdhost.hlp
As far as I can tell it's not linked to anything that's why I never found it right away.
Thanks for everyones help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top