Equivalent of #include 
Author Message
 Equivalent of #include

I'm a C++ guy, trying to learn VB  (VB6).

Is there any equivalent of the #include directive from C?
I want to include the text from one file as part of the s
source code.  I couldn't find one.



Sat, 30 Apr 2005 05:44:10 GMT  
 Equivalent of #include
There's nothing like that in VB. You can add references to external
components at will but there's no #Include functionality at all. You can
always create a class module from the code you want to include and add that
class to as many projects as you want.

--
Ken Halter - MS-MVP-VB - Please keep it in the groups..
http://www.vbsight.com - http://www.vbsight.com/MultiColumn.htm
http://www.vbsight.com/TBGDialogCTL.htm

Quote:
> I'm a C++ guy, trying to learn VB  (VB6).

> Is there any equivalent of the #include directive from C?
> I want to include the text from one file as part of the s
> source code.  I couldn't find one.



Sat, 30 Apr 2005 06:16:41 GMT  
 Equivalent of #include
Include is a way of managing the scope of declarations - and VB has simpler
scope rules.  If the source file is in the project then it has global
scope - essentially all elements of a VB project that have global scope
"are" separate source files.  So -- while I can think of some things that
might be nice about having includes for share code between projects within a
project they wouldn't do you much good.

Later, Charles



Sat, 30 Apr 2005 07:15:03 GMT  
 Equivalent of #include
Thanks.  Actually, while that is the most common use of
#include, that isn't what it does.  What it actually does
is simply insert text from one file into another, and that
is what I needed.

I have a project that passes lots and lots of parameters
around for display in a lot of different ways, and so I
get functions with huge argument lists.  In C, I would
create structures that include all the parameters, but I
want it web-accessible, and that means Dispatch
interfaces, and that means simple types, and that means
long argument lists.  (The operations might involve 70
parameters, and I don't know a better way to pass them
than passing 70 parameters as function arguments.)

 And the marketing folks in our company constantly make
promises to customers for new features that require
changes to these lists.  Then, they don't understand why I
tear my hair out because I "only have to add one
parameter".  Well, yes, but it is one parameter out of 70,
and it gets passed through about 13 function calls just
like that, and I know that they will change it again next
week.

It got bad enough that I decided to automate the
programming.  I now have a database that generates
function calls based on arguments.   I have some C++ code,
and some VB code.  Now, in my C++ code, I have a lot of
statements like

#include "functiondefinition.h"
{//body of function

Quote:
}

and the functiondefintion.h file contains
HRESULT myfunction {int myfirstarg, BSTR myotherarg, ....
long my73rdarg)

which is generated by reading a VARNAMES database.

It's a bit screwy, but I like it.  I can respond to the
marketing department much faster since I did it.

But in the case of the VB code, after generating the
files, I have to open each project, and do a cut of the
old version and insert the new.  Not a huge problem, but
more difficult than the C code.

And so, if there is anyone out there reading this from the
VB marketing and future feature development team, I just
want to point out that variable scope isn't the only
reason for having an #include directive.  Sometimes, you
just want to stick some boilerplate code into somewhere,
or in my case, some automatically generated code.

Quote:
>-----Original Message-----
>Include is a way of managing the scope of declarations -
and VB has simpler
>scope rules.  If the source file is in the project then
it has global
>scope - essentially all elements of a VB project that
have global scope
>"are" separate source files.  So -- while I can think of
some things that
>might be nice about having includes for share code

between projects within a
Quote:
>project they wouldn't do you much good.

>Later, Charles

>.



Sat, 30 Apr 2005 22:04:50 GMT  
 Equivalent of #include
Well the VB answer to what you want is classes.  Define classes to contain
your parameters along with the methods to manipulate them - and pass around
the objects.  If the classes are defined as public they will be accessible
to anyone that creates them (including ASP.)   An object is more transparent
to the end-user developer than functions and you can actually manage the
'properties' of the object as an array (or some other open-ended structure)
that would allow you to add 'properties' without breaking existing code or
requiring changes to the class interface.

Later, Charles



Sat, 30 Apr 2005 23:39:18 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Equivalent of #include under WSH?

2. Equivalent to #include in eVB

3. Equivalent for C language include in VB

4. Equivalent for C language include in VB

5. "#INCLUDE FILE=" equivalent for ASP pages using VB?

6. Application Unload Equivalent

7. RES String Table Equivalent

8. FileDialog Object equivalent in Access 2000?

9. vba equivalent of In statement?

10. Access equivalent for Macro substitution inf FOXPRO

11. Access equivalent of Excel code?

12. Access equivalent of Dialogs(wdDialogFileOpen).Show

 

 
Powered by phpBB® Forum Software