Groups | Blog | Home
all groups > vb.net > january 2007 >

vb.net : VB FAQs (Interview Questions) lot lot


shamirza
1/15/2007 9:35:52 PM
Question
Do ActiveX DLLs made in VB still need the VB runtimes on
the
machine?

________________________________________
Answer
In a word, Yes.

Visual Basic does not support what is known as "Static
Linking". What that means is that all componets, controls,
and applications developed with Visual Basic, also requier
the Visual Basic Runtime libraries.


Question
What is a circular reference? Why is it bad?

________________________________________
Answer
Consider two objects, A and B. A holds a reference to B,
and B holds a reference to A. A only releases its
reference to B when A terminates. B only releases its
reference to A when B terminates. Since neither A nor B
will terminate until all active references to them are
released, A and B are now immortal (which might sound cool,
but is really a 'bad thing').

Circular references should be avoided whenever possible,
but in some designs they can be unavoidable. For those
cases, there are various methods for "breaking" circular
references. One technique is to require the client to
manually clear them (eg. Set A.BReference = Nothing or call
a method which releases the reference). Another technique
is to use unsupported functions (ObjPtr, etc.) to get a non-
binding reference to the object. Yet another method is to
use a proxy object to dynamically obtain a reference which
is held only for the duration of the call

Question
What is meant by "Early Binding" and "Late Binding"? Which
is better?

________________________________________
Answer
Early binding and late binding refer to the method used to
bind an interface's properties and methods to an object
reference (variable). Early binding uses type library
information at design time to reference procedures, while
late binding handles this at run time. Late binding
handles this by interrogating the reference before each
call to insure that it supports a particular method. Since
every call to a late bound object actually requires two
calls ("Do you do this?" followed by "Okay, do it then"),
late binding is much less efficient than early binding.
Except where early binding is not supported (ASP,
scripting, etc.), late binding should only be used in very
special cases.

It is a common misconception that any code using the
CreateObject function instead of Set = New is using late
binding. This is not the case. The type declaration of
the object variable determines whether it is late or early
bound, as in the following:

Dim A As Foo
Dim B As Foo
Dim C As Object
Dim D As Object

Set A = New Foo 'Early Bound
Set B = CreateObject("FooLib.Foo") 'Early Bound
Set C = CreateObject("FooLib.Foo") 'Late Bound
Set D = New Foo 'Late Bound


Question
I have been reading on the topic callin win32 APIs, but as
I think its a very complex topic I hope anyone can help me
sort it out a little more when answering my question:

In what kind of circumstances do you actually have
use accessing WIN32 API?

________________________________________
Answer
There are approximately 15,000 functions included in the
WIN32 API. It's a 'collection' of functions that make up
the 'guts' of how Windows works.

Every application uses these functions to 'be' a Windows
application. In VB we are just shielded from most of it
because they wrote a bunch of 'wrapper' functions over the
API's for us.

Sometimes however they didn't give us all the functionality
we need and we will have to use a specific API function
ourselves to overcome this limitation. There are a number
of areas where we can do this. Actually just about
anything and anywhere.

However below you will find some quick examples of 'why' we
would use the API directly. As far as the AddressOf
operator, this is because some API functions require
a 'callback' function. This is a routine that the API will
call when it has finished it's processing and wants to let
you know it's 'your turn' again.

Some examples...

* Putting icons in the System Tray

* Getting / Setting text to other applications (commonly
called "Screen-Scrapping")

* Creating high precision timer functions (vb's are very
limited)

* Subclassing a form or window (<--too much here to
explain shortly)

* Making a specific window always being on top of other
windows
Question
Why do so many example programs not use the DLL name
directly without an alias? Surely the DLL names do not
commonly clash with existing names.

________________________________________
Answer
There are a lot of reasons to use aliases. For instance, the
SendMessage API. You need to change the data types you are
sending to the API, so you need to have multiple
declarations of the same API.

There are many structures (UDTs) which are bigger or smaller
in NT than they are in Win9x. So, again, you need to change
what UDT you are pointing at depending on the OS. Since you
can''t do this on the fly, you need to write to different
declares.

Also, there are a lot of APIs that need to differentiate
between whether you are sending it a unicode or an ansi
string.

Question
What is a hWnd and what can it be used for?
Code examples for different kinds of usage are welcome.

________________________________________
Answer
An hWnd is a Handle to a Window if you will. A handle is a
long integer generated by the operating system so it can
keep track of the all the objects (a form, a command button
etc.)

You can't set a hwnd at design or runtime, and the value of
the handle changes each time the form is opened. Handles
are used when you make calls to API functions, the function
needs to know the handle of the window, plus other
arguements depending on the what
the API does.

The GetWindowsText API frx:

Declare Function GetWindowText Lib "user32" alias _
"GetWindowTextA" (byval Hwnd as long, byval lpstring as _
string, byval cch as long) as Long

Assuming the object in question is a form, passing the hwnd
of the form to the api will cause a search to performed in
windows internal data structures looking for that handle,
and then return what text is in the forms title bar
or caption.

Question
Is there an event that fires when an application loses the
focus (Deactivate fires when a form loses focus to another
form in the same app, but not when I bring another
application to the front).

________________________________________
Answer
No event fires ... but the active window receives the
WM_ACTIVATEAPP message.

Question
How can I close another program?

________________________________________
Answer
You have to use the API - here's a code example, you'll
need to create a CommandButton called "Command1" on a form
and paste this code in. You'll need to modify the function
call under the Command1_Click event to reflect the Window
Caption \ Class you are trying to close.

aaron.kempf NO[at]SPAM gmail.com
1/16/2007 11:25:34 AM
Stephany;

for the record; I was posting in this newsgroup a couple of months ago;
asking for information like this.. and NOBODY ANSWERED ME

please feel free to post things like this into the newsgroup whenever
you want

all VB people are welcome in _ALL_ vb newsgroups

-Aaron


[quoted text, click to view]
Stephany Young
1/16/2007 7:27:49 PM
[quoted text, click to view]

Why did you bother posting this in this particulat newsgroup?

Come to that, why did you bother posting it at all?


Herfried K. Wagner [MVP]
1/17/2007 1:39:35 AM
"Stephany Young" <noone@localhost> schrieb:
[quoted text, click to view]

In addition, note that the questions target VB6 and not VB.NET specifically.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Stephany Young
1/17/2007 1:54:16 PM
That's thae reason I asked the question.


[quoted text, click to view]

aaron.kempf NO[at]SPAM gmail.com
1/18/2007 12:11:02 PM
you guys are WRONG.

microsoft broke the rules and traditions of newsgroups; the dipshit
project manager that decided to name the 'newsgroup for the current
version of vb' to be this verbose:

microsoft.public.dotnet.langauges.vb

SHOULD BE DRAWN AND FUCKING QUARTERED

newsgroups shouldn't have thier name changed from microsoft.public.vb
to dotnet.vb; for starters; I am not ever going to use a product named
VB DOTNET.

I use a product called VB TWO THOUSAND FIVE

VB.NET didn't have edit and continue so VB.net can suck my salty balls

-Aaron


[quoted text, click to view]
Bruce W. Darby
1/18/2007 11:57:40 PM
Aaron,

I doubt that MS would do something so unsanitary as taking something out of
your mouth and putting it into their own.


[quoted text, click to view]

aaron.kempf NO[at]SPAM gmail.com
1/19/2007 9:08:28 AM
eat shit mofo

why am i writing about VB 2005 in a newsgroup that is called DOTNET?

the product i use is NOT called DOTNET

-Aaron



[quoted text, click to view]
rowe_newsgroups
1/19/2007 10:41:33 AM
Since I'm breaking my personal rule to not feed trolls, I'll only
respond just this once. Here it goes:

You do know the difference between a programming language and an IDE
right?

You see, having VB2005 (the name of the IDE) isn't even required to
program on the .Net platform. All you need is to have .Net installed on
the pc, and some form of text editor. As a matter of fact, I can
program a complete Vb.Net program using Notepad - but the language I'm
using is still vb.net. Most people just use the ide to get the features
like breakpoints, designers, object browser, intellisense, etc. But
they are in no means required.

So should Microsoft name the newsgroup after the actual
language/version (VB DotNet) or after the most commonly used
developer's environment (vb 2005)? I say they chose right in naming it
after the language version.

Oh, and seeing how you always curse wildly and tell responders to eat
something, you can just leave that off of your further posts - we'll
just assume it's included.

Thanks,

Seth Rowe


[quoted text, click to view]
Bruce W. Darby
1/19/2007 10:20:21 PM
Seth,

His response isn't showing the same 'zing' anymore. I think he's running out
of epithets to hurl around. :) But you make a truly valid point in your
post. Will he accept it, however?

Bruce

[quoted text, click to view]

aaron.kempf NO[at]SPAM gmail.com
1/21/2007 3:05:41 PM
eat a dick fag

it's not called VB.net

the language is NOT called VB.net it has NOT BEEN CALLED VB.NET for
what.. 15 months?

the language was RENAMED from VB DOTNET to VB 2005 BECAUSE THE PHRASE
DOTNET, THE MONIKER-- is a complete failure

Seriously.

Please show me one piece of literate from MIcrosoft that calls it 'vb
dotnet 2005'

-Aaron

[quoted text, click to view]
aaron.kempf NO[at]SPAM gmail.com
1/21/2007 3:05:51 PM
eat a dick fag

it's not called VB.net

the language is NOT called VB.net it has NOT BEEN CALLED VB.NET for
what.. 15 months?

the language was RENAMED from VB DOTNET to VB 2005 BECAUSE THE PHRASE
DOTNET, THE MONIKER-- is a complete failure

Seriously.

Please show me one piece of literatature from MIcrosoft that calls it
'vb dotnet 2005'

-Aaron

[quoted text, click to view]
aaron.kempf NO[at]SPAM gmail.com
1/21/2007 3:08:47 PM
I militantly disagree with your diagnosis

maybe if you weren't infected with DOTNET then maybe you wouldn't be
such a dipshit

I'll never use a language named DOTNET

the IDE is not called DOTNET
the LANGUAGE is not called DOTNET

the faggot that renamed the 'main vb newsgroup' from
microsoft.public.vb to microsoft.public.dotnet.languages.vb is a
fucking idiot

the fucking idiot that pulled the DNS redirect for microsoft.com/vb
should be shot

newbies come to microsoft.com/vb and they think 'oh shit, ms has killed
VB'
newbies come to microsoft.public.vb and they think 'oh shit, ms has
killed VB'

it's a marketing thing, and you're no KENNEDY fucker


-Aaron


[quoted text, click to view]
aaron.kempf NO[at]SPAM gmail.com
1/21/2007 3:17:25 PM
please _FAG_ please please tell me _ANYWHERE_ that it says DOTNET at
this location

http://msdn.microsoft.com/vstudio/express/vb/

and for the record; what kindof studid fucking URL is this:
http://msdn.microsoft.com/vstudio/express/vb/

I shouldn't have to write VSTUDIO; that is an abbreviation
I shouldn't have to write MSDN; I don't subscribe to MSDN

WHEN MICROSOFT BRINGS THE VISUAL OR THE BASIC BACK TO VISUAL BASIC IS
WHEN I STFU

-Aaron



[quoted text, click to view]
shamirza
1/23/2007 3:16:38 AM
Forgot every all past messages....bosses... why the hell we are
fighting....
what ever microsoft does is for people's. He is simple great from my
personal
view. Thanks to all microsoft supporters. hey hey hey.... :)

[quoted text, click to view]
AddThis Social Bookmark Button