a strange thing on using ATL

sunyuchen
sunyuchen used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Author of the Year 2009
Commented:
maybe there is no function or variable named TestLib
-- Dan

Author

Commented:
Hi, Dan
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
Author of the Year 2009

Commented:
Maybe the book Inside COM has a clue or two.

-- Dan
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Author

Commented:
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.
Author of the Year 2009

Commented:
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

Author

Commented:
what do u mean use the use the same name?
Author of the Year 2009

Commented:
>>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

Commented:
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
Force accepted

** Mindphaser - Community Support Moderator **

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial