Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed May 24, 2017 6:56 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Running VB6 Dll Class
PostPosted: Tue May 29, 2012 7:35 am 
Offline

Joined: Fri May 11, 2012 7:43 am
Posts: 14
Good afternoon All,

After issues i had trying to dll a API/C-type DLL i make a COM wrapper dll via a class in VB6 which i know works as i have tested in VB6.

I have tried running it in RB but to no avail.

VB6 Code:
Dim calc As DLL180512.sumDLL

Set calc = New DLL180512.sumDLL

Call calc.inputinfo(0, 1)
Call calc.inputinfo(0, 1)
Call calc.inputinfo(1, 32)

calc.RunCalc

MsgBox ("Output: " + calc.Demon) ' Simple result processing


Below is the RB code:
Dim calc as DLL180512.sumDLL
calc = new DLL180512.sumDLL

calc.inputinfo(0,1)
calc.inputinfo(1, 32)
calc.inputinfo(2,50)

calc.RunCalc

Msgbox("Output: " + CALC.Demon)' Simple result processing


There is more to load the input info but i have negated it, it stalls on the first calc.inputinfo(0,1). Is there a RB alternative to Call for a sub?

Thank you in advance.


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 1:35 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
RB can make use of OLE objects, but I don't think that

Dim calc as DLL180512.sumDLL
calc = new DLL180512.sumDLL

is the right syntax.

That said, you say the error occurs on the first call to calcinfo?

I notice you don't have the word Call there.
Call is used to 'get and discard' the return value.

What is the actual error you are getting, and is the DLL registered on the RB development machine?


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 3:02 am 
Offline

Joined: Fri May 11, 2012 7:43 am
Posts: 14
Hello Kermit,

the first error occours on the

calc.inputinfo(0,1)


I have tried with with

call calc.inputinfo(0,1)


but it still fails at the same point. and yes the dll is registered to the computer. It is eailsy found on the add activex component refernece list.

The intial creating the instance seems to work fine in VB6. Is it not the same syntax in RB? I notice there is no alternative to "Set". is this correct?

The error i am reciving is "Parameters are not compatable with this function".

I designed the function to accept an integer then a double, on the function description in the bottom staus bar it says the function revieces an int16 type and a double. do i need to cast these in their location?

i also read somewhere that i need to Declare the functions, but is this correct for a COM type class based dll?

thank you,


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 3:07 am 
Offline

Joined: Mon May 30, 2011 12:56 am
Posts: 702
Quote:
I designed the function to accept an integer then a double, on the function description in the bottom staus bar it says the function revieces an int16 type and a double. do i need to cast these in their location?


Given the nature of the message, in your shoes I wouldn't pass hard coded values in like that.
Try declaring the parameters explicitly

dim param1 as uint16
dim param2 as double

param1 = 0
param2 = 1
calc.inputinfo(param1,param2)


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 4:02 am 
Offline

Joined: Fri May 11, 2012 7:43 am
Posts: 14
Thank you,

i did indeed give that a bash after my last post and it worked. its a bit laborious so i will edit my dll to accept variants. then type cast locally to the dll. hopefully this will sort out any problems.

RB doesnt seem to quite self manage types like VB6 does. i know its poor practise to allow the complier to do the donkey work but it does make life eaiser.


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 4:04 am 
Offline

Joined: Fri May 11, 2012 7:43 am
Posts: 14
or i could create a new custom function which loads the dll's parameters for me via RB, type casting in a secondary function basically, instead of doing quickly. will try that.


Top
 Profile  
 
 Post subject: Re: Running VB6 Dll Class
PostPosted: Wed May 30, 2012 4:40 am 
Offline

Joined: Fri May 11, 2012 7:43 am
Posts: 14
Done! SMASH!!! it works just fine,

Inside a module:

sub LoadDll(byref Calcdll as calcdll, location as variant, number as variant)
dim i as int16
dim j as Double

i= location
j =number

call calcdll.inputinfo(i,j)
end sub


in the form:

Dim calc as calcDLL180512.calcDLL
calc = new calcDLL180512.calcDLL

call loaddll(calc,0,1)
call loaddll(calc,1,32)
call loaddll(calc,2,50)
call loaddll(calc,5,2000)
call loaddll(calc,14,4)
call loaddll(calc,15,10)
call loaddll(calc,16,2)
call loaddll(calc,17,4)
call loaddll(calc,18,500)
call loaddll(calc,26,7)
call loaddll(calc,27,12)
call loaddll(calc,51,0)

calc.RunCalc

Msgbox("Result: " + CALC.Result)'


simple when you think about it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group