Thanks again,
I suppressed the Main() sub and it works.
I don't know whether it's relevant, but i use VB.net in the ASP.Net context,
so i don't think that Sub Main() is relevant here .... I remember that is
was indeed used in VB language.
About putting the code in code-behind or in a .vb file question, again it's
related to ASP.Net where all files containing classes must be placed in
subdir APP_Code. Code-behind is the VB.Net part of an aspx file ...
"Branco Medeiros" <
[email protected]> schreef in bericht
André wrote:
So, the Sub Main() is completely useless?
Nope. I mean, it *is not* useless.
See, Subs, in general, are methods that do things, from which you
don't expect a result. Functions, on the other side, usually calculate
things and return a result, although most languages (including VB)
allow you to implicitly discard the Function's result and call the
Function as if it was a Sub -- for what we call "the function's side-
effects" (notice, however, that a Sub *can't* be used as a Function.
Could you guess why?). Properties allow you access to the internal
state of an object. A Property is like the mixing of a Sub to *set*
the value with a function to *get* it back (that's why properties are
usually called, in some languages, getters and setters).
Now, Sub Main has, for historical reasons, the job of marking the
entry point of the "application". It's the first method to be called
by the framework when it is about to execute your code.
To be used like this, the Sub Main has to be a Shared method in a
class, or it must be declared in a Module. And, of course, you must
indicate to the compiler which Sub Main is *the* main sub (usually in
the application properties, if you're using the MS IDEs).
And is it possible to put the code in code-behind, or it must be put, like
a
class, in a .vb file?
<snip>
Unfortunately I have no idea of what you're asking. Maybe you can
state your question more clearly...
HTH.
regards,
Branco.
"Branco Medeiros" <
[email protected]> schreef in bericht
André wrote:
So, the Sub Main() is completely useless?
Nope. I mean, it *is not* useless.
See, Subs, in general, are methods that do things, from which you
don't expect a result. Functions, on the other side, usually calculate
things and return a result, although most languages (including VB)
allow you to implicitly discard the Function's result and call the
Function as if it was a Sub -- for what we call "the function's side-
effects" (notice, however, that a Sub *can't* be used as a Function.
Could you guess why?). Properties allow you access to the internal
state of an object. A Property is like the mixing of a Sub to *set*
the value with a function to *get* it back (that's why properties are
usually called, in some languages, getters and setters).
Now, Sub Main has, for historical reasons, the job of marking the
entry point of the "application". It's the first method to be called
by the framework when it is about to execute your code.
To be used like this, the Sub Main has to be a Shared method in a
class, or it must be declared in a Module. And, of course, you must
indicate to the compiler which Sub Main is *the* main sub (usually in
the application properties, if you're using the MS IDEs).
And is it possible to put the code in code-behind, or it must be put, like
a
class, in a .vb file?
<snip>
Unfortunately I have no idea of what you're asking. Maybe you can
state your question more clearly...
HTH.
regards,
Branco.