sunyuchen
asked on
a strange thing on using ATL
Hi, i built a ATL last time. when added it into a vb project like below, it works well.
'''''''''''''''''''''''''' '''''''''' ''''''''''
Private Sub Command1_Click()
Dim r As New ATLINBTWNLib.InsideCOM
r.TestLib (2) <-- compile error here
End Sub
'''''''''''''''''''''''''' '''''''''' '''''''''' '''
but after i changed sth in the ATL, (add a new method), once i did the above things again, it always give me a "compile error: expected function or variable" on TestLib the method.
but, when i type r. it can show me a list a method, but why it fails in compilation? what could be possible solution? thanks
''''''''''''''''''''''''''
Private Sub Command1_Click()
Dim r As New ATLINBTWNLib.InsideCOM
r.TestLib (2) <-- compile error here
End Sub
''''''''''''''''''''''''''
but after i changed sth in the ATL, (add a new method), once i did the above things again, it always give me a "compile error: expected function or variable" on TestLib the method.
but, when i type r. it can show me a list a method, but why it fails in compilation? what could be possible solution? thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Maybe the book Inside COM has a clue or two.
-- Dan
-- Dan
ASKER
hi, Dan
i read the book and tried the ATL in these days. i found the error comes from when i declare more than one arugments in the method. see below:
STDMETHODIMP CStdLib::Test1st(BSTR src)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP CStdLib::Test2nd(BSTR src, BSTR des)
{
// TODO: Add your implementation code here
return S_OK;
}
and in VB the codes are:
Dim myRef As New TESTSNDLib.StdLib
myRef.Test1st (src)
myref.Test2nd(src, des) <--- compile error" expected:= "
at first, why the 2nd method give me a comile error like that? it is exactly the same as 1st except has one more arugment.??
and if i changed it into:
a = myref.Test2nd(src, des) <--- comile error " expected funtion or variable "
well, it is really confusing me. can i can not define where goes wrong.
what do u think? is it vb problem or ATL problem. I think mainly ATL problem. :(
hi, Dan, my objective is to build a ATL and pass two string value and one integer value into the ATL function. Do u mind to do a try for me and tell me how to achieve this in ATL? thank you very much.
i read the book and tried the ATL in these days. i found the error comes from when i declare more than one arugments in the method. see below:
STDMETHODIMP CStdLib::Test1st(BSTR src)
{
// TODO: Add your implementation code here
return S_OK;
}
STDMETHODIMP CStdLib::Test2nd(BSTR src, BSTR des)
{
// TODO: Add your implementation code here
return S_OK;
}
and in VB the codes are:
Dim myRef As New TESTSNDLib.StdLib
myRef.Test1st (src)
myref.Test2nd(src, des) <--- compile error" expected:= "
at first, why the 2nd method give me a comile error like that? it is exactly the same as 1st except has one more arugment.??
and if i changed it into:
a = myref.Test2nd(src, des) <--- comile error " expected funtion or variable "
well, it is really confusing me. can i can not define where goes wrong.
what do u think? is it vb problem or ATL problem. I think mainly ATL problem. :(
hi, Dan, my objective is to build a ATL and pass two string value and one integer value into the ATL function. Do u mind to do a try for me and tell me how to achieve this in ATL? thank you very much.
The object is declared as
myRef
then when you use
myref
you get errors. Does the error go away if you use the same name?
-- Dan
myRef
then when you use
myref
you get errors. Does the error go away if you use the same name?
-- Dan
ASKER
what do u mean use the use the same name?
>>what do u mean use the use the same name?
SOrRy, i sHOUld haVe TRieD tO Be cLEarer: I mean "if you spell the variable the same in both cases"
-- Dan
SOrRy, i sHOUld haVe TRieD tO Be cLEarer: I mean "if you spell the variable the same in both cases"
-- Dan
This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity, I will suggest to accept
"DanRollins"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity, I will suggest to accept
"DanRollins"
comment(s) as an answer.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Force accepted
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
ASKER
oh, no, the ATL is created by me. there is such a function. btw, i also asked my friend, i got such comment.
///////////
I just tested the ATL, I can not create the instance of the class in VB, the message says "Active X component can not create Object"
I looked at the code, the problem is in your ATL code, the
ATLINBTWNLib.InsideCOM is not public createable.
///////////
what do u think of it? how to make it public createable?
thanks
--Eric