Home > Archive > MCSD > April 2002 > what do u thin ?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author what do u thin ?
tamerelrefaie

2002-04-18, 6:20 am

Hello everybody,

I faced this question several times and everytime I see different answer so what do u think about it

You have created a VB application that uses a COM component. The COM component will communicate with your application by calling a method of one of your applications objects. What should your application do to enable this type of communication?

A: Create an object and pass the address of that object to the COM component by using the AddressOf operator

B: Create an object and pass the reference of that object directly to the COM Component.


and plz tell me why do u choose ur answer

I'll be waiting 4 ur reply

thanx a lot everybody
tamer
vobedkov

2002-04-19, 2:57 am

I think it sounds more natural to use reference to the object. So answer B - is simplest way to do that.
Furthermore AddressOf is used only with procedures.

"A unary operator that causes the address of the procedure it precedes to be passed to an API procedure that expects a function pointer at that position in the argument list." - MSDN



Good luck!
tamerelrefaie

2002-04-20, 1:34 am

Thanx a lot vobedkov,
I really appreciate ur effort in searching for me for the right answer, honestly I searched in the MSDN but I didn't reach to something and I was truelly not sure about the right answer.

thanx again my dear

tamer
fwitcher

2002-04-22, 6:41 am

I used to get confused as well but now know (through repeat exposure to this question) that the correct answer is B.

This question is testing your knowledge of using CALLBACK functions.

There are two types of Callback scenarios. One is where the function being called is a function in a standard module. Here you need to use the AddressOf function to indicate (and idenitfy physically) which function needs to be executed.

The other scenario is where the function you need to call exists as a method of a custom made object (eg is in a class module). The simplest way to call this function is to pass the reference to the object to the place where the call will be made.

You are basically passing an object variable by reference, so you can manipulate it, including calling its methods.

the code that does the callback might look like this:

Public Sub CallMethod(by Ref objClient as MyObject)

'manipulate the object that
'has been passed in
objClient.Method

End Sub
Hope that helps.
Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net