Re: Bogged down on things
- From: "mayayana" <mayayanaXX1a@xxxxxxxxxxxxxxxx>
- Date: Sun, 30 Oct 2005 15:27:27 GMT
The best book that I can think of is
VB and VBA in a Nutshell by Paul Lomax.
(It's an O'Reilly book. They usually have the best
books on most topics, in my experience.)
There are chapters in the berginnig that clearly
explain general VB topics.
Another good one if you can find it is VB6 Complete.
Sybex puts out the "Complete" series. I've found that
they do a good job of compiling writings from various
sources to create a well-rounded anthology at a
low price.
There are a lot of other VB6 books (if you can still find
them) but most are just beginner sample books that
you'll only find useful for a couple of weeks. Like the
"for Dummies" books, they can be handy, but you'll
outgrow them fast and buying a second one is a waste
of money.
Your questions seem to be mainly issues that will
resolve themselves with coding. And some of them
are a matter of preference.
--
mayayanaXX1a@xxxxxxxxxxxxxxxx
> There's a number of fundamental things that I seem to be getting bogged
down
> on in VB6 and it's mainly to do with variables & subs. Things like, in
subs,
> what ByVal does and when it's needed;
ByVal means the value is passed. ByRef means the address of
the variable is passed. VB defaults to ByRef, which is faster
within an EXE, but it also means that you have to be aware
your variable can be altered. In other words, if you pass a string
to a function and the function changes the string internally, then it is
also changed in the function that made the call. The reason for that
is because VB passed the address of the variable - so both
functions are dealing with the same variable.
For instance, you can treat a sub like a function by sending
it a ByRef variable. Ex.:
Sub Clip(String1)
String1 = Left$(String1, 2)
End Sub
That sub would clip a string to 2 characters. You could
call it like so:
Clip s1
That would act like a function because you would "get back"
s1 clipped. The Clip sub is acting on s1 directly. It's a
confusing way to code, but it works.
-----
Except with API calls you usually don't need to worry about
ByVal.
> when and why you need the "optional"
> keyword;
A matter of preference. There are usually several ways that
you can design a function. It just depends on what works
best. If you use optional parameters you will usually need
to check for them by using something like:
If Not IsMissing(xyz) then .....
>
>passing arrays to and from a sub; returning vars from a sub in
> general; when you need the () after an array name; etc
>
Usually if you want to pass a value back you'd use
a function. If you want to return an array just use
a variant type:
Function GetArray() as Variant
When you pass the array you won't use the ().
It's a bit involved beyond that. You might want to read
up on dynamic vs. fixed arrays.
.
- Follow-Ups:
- Re: Bogged down on things
- From: IanW
- Re: Bogged down on things
- References:
- Bogged down on things
- From: IanW
- Bogged down on things
- Prev by Date: Re: Deploying a DHTML app
- Next by Date: Re: Bogged down on things
- Previous by thread: Bogged down on things
- Next by thread: Re: Bogged down on things
- Index(es):
Relevant Pages
|