Link to home
Start Free TrialLog in
Avatar of eladr
eladr

asked on

writing active x dll

see this very simple active x im trying to write:

Function getDataFromXor(cardID As Long, name As String, expirDate As Date, price As Integer) As String
    'variable dcleration
    Dim myData As String
    'decleraing my other com object that get 4 parameters
    Dim xorObj As New myXorObj.GetData
    'saving the data into variable - just for future use
    myData = cardID & "|" & name & "|" & expirDate & "|" & price
    'insert parameters into the other active x
    myXorObj.GetData(cardID As Long, name As String, expirDate As Date, price As Integer) As String
End Function

i always got : compile error: expected:list seperator or )  
in this line:
myXorObj.GetData(cardID As Long, name As String, expirDate As Date, price As Integer) As String
Avatar of fbtcell
fbtcell

Try something like :

Dim myString as String
....
myString = myXorObj.GetData(cardID, name, expirDate, price)

GetData is a function of your myXorObj object? it should pass parameters like so:

Dim returnString As String
returnString = myXorObj.GetDate(cardID, name, expirDate, price)

it returns a string but i'm not sure where you want to store it or what you need to use it for.
Avatar of eladr

ASKER

i got 2 dll.
one (as i posted the code) should get
4 parameters and insert them to the other com.
the "other com" is myXorObj
which has one function : getData.
i referenced to the object:
Dim xorObj As New myXorObj.GetData
but i got errors all  the time in the line that insert the 4 parameters to the other com
elad

   
Avatar of eladr

ASKER

Function getDataFromXor(cardID As Long, name As String, expirDate As Date, price As Integer) As String
    'variable dcleration
    Dim myData As String
    Dim myString As String
    'decleraing my other com object that get 4 parameters
    Dim xorObj As New myXorObj.GetData
    'saving the data into variable - just for future use
    myData = cardID & "|" & name & "|" & expirDate & "|" & price
    'insert parameters into the other active x
    myString = myXorObj.GetData(cardID, name, expirDate, price)
End Function
now i got method or data member not found
in this dll...have you referenced the other dll by going to project -> REFERENCES and checking it off?

also you declare the variable:
Dim xorObj As New myXorObj.GetData

is GetData the correct class name of that dll?  is it also the name of the function?

even so, then you need to use the variable you declared:

myString = xorObj.GetData(cardID, name, expirDate, price)
GetDatafromXor = ReturnString surely
GetDatafromXor = MyData
Avatar of eladr

ASKER

hi all...
i solved the problem.
now i have other one and for this one i will
post the points:

this is my simple com and everything works good.

<%
set xorObj = server.createObject("getDataFromXor.getDataFromXorClass")
'com parameters
retuenAccess = xorObj.getDataFromXor("01258528","elad","3/2/00","45")
'answer from xor
response.write "Answer from xor:" & retuenAccess
%>

when im using variable instead of hard coded i got error:

<%
dim cardID
cardID="01258528"
set xorObj = server.createObject("getDataFromXor.getDataFromXorClass")
'com parameters
retuenAccess = xorObj.getDataFromXor(cardID,"elad","3/2/00","45")
'answer from xor
response.write "Answer from xor:" & retuenAccess
%>
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'getDataFromXor'

/xor/xor.asp, line 18
ASKER CERTIFIED SOLUTION
Avatar of HiThere
HiThere

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eladr

ASKER

i will give it a try...
elad
You could also try
retuenAccess = xorObj.getDataFromXor(clng(cardID),"elad","3/2/00","45")

Similarly for other variables do the conversion to the correct datatype required for the DLL and then call the function.

retuenAccess = xorObj.getDataFromXor(clng(cardID),Cstr(StringVariable),CDate(DateVariable),Cint(IntegerVariable))

Avatar of eladr

ASKER

i tried hithere solution:
mystring = xorObj.GetData (ByVal cardID As Long,byVal name as String,byVal expirDate As Date,byVal price As Integer) As String

but i got compile error-syntax error
Avatar of eladr

ASKER

i tried manoj_r  solution and it's works.
but i prefer inside dll function solution
eladr
Both manoj_r and hithere solution should work for you.

You can change function to

e.g. getDataFromXor(cardID As Variant, name As Variant, expirDate As Variant, price As Variant)


8->
As HiThere has mentioned you have to change the function defination in VB.  Replace your function declaration fro getDataFromXor with
(ByVal cardID As Long,byVal name as String,byVal expirDate As Date,byVal price As Integer) As String



abd from your asp page call it as
mystring = xorObj.GetData (cardID ,name ,expirDate,price)


Avatar of eladr

ASKER

HEY...
I think i missing something here...
im always got syntax error!

this is my function...
the error is on the line :
mystring = xorObj.GetData(cardID As Variant, name As Variant, expirDate As Variant, price As Variant)


Function getDataFromXor(cardID As Long, name As String, expirDate As Date, price As Integer) As String
    'variable dcleration
    Dim myData As String
    Dim mystring As String
    'decleraing my other com object that get 4 parameters
    Dim xorObj As Object
    'insert parameters into the other active x
    Set xorObj = CreateObject("myXorObj.myXorObjclass")
    mystring = xorObj.GetData(cardID As Variant, name As Variant, expirDate As Variant, price As Variant)
    getDataFromXor = mystring
End Function
Avatar of eladr

ASKER

got it...got it...
i should do the byVal in the top define function...
correct?
elad
Correct !
I hope this will work

Function getDataFromXor(ByRef cardID As Variant, _
                        ByRef name As Variant, _
                        ByRef expirDate As Variant, _
                        ByRef price As Variant) As String
    'variable dcleration
    Dim myData As String
    Dim mystring As String
    'decleraing my other com object that get 4 parameters
    Dim xorObj As Object
    Dim lCardID As Long
    Dim strName As String
    Dim dtExpirDate As Date
    Dim mPrice As Integer
   
    lCardID = cardID
    strName = name
    dtExpirDate = expirDate
    mPrice = price
    'insert parameters into the other active x
    Set xorObj = CreateObject("myXorObj.myXorObjclass")
    mystring = xorObj.GetData(lCardID, strName, dtExpirDate, mPrice)
    getDataFromXor = mystring
End Function

Function GetData(ByRef ICardID As Long, _
                 ByRef name As String, _
                 ByRef expirDate As Date, _
                 ByRef price As Integer) As String
                 
'your code

End Function
What's going on with this question.  
Surely fbtcell and azrasound answered it already.
You can't put:-
myXorObj.GetData(cardID As Long, name As String, expirDate As Date, price As Integer) As String
in the middle of a function.  This looks more like a function declarartion as opposed to a function call.
Avatar of eladr

ASKER

sorry dave_b
u right but many others already answered
this!
Avatar of eladr

ASKER

im closing the que.
hithere will get all points.
i will post new que. with 10 points to manoj_r also.
i want to thank you all for helping me so much.
eladr
Avatar of eladr

ASKER

thanks again...