Angela
Angela

Reputation: 111

how to include a header file in VB

I can write program VB 6.0, but I don't know how to include a file in VB 6.0. In c it was

include "aa.h"

But I really don't know how to include this "aa.h" in my VB program.

Upvotes: 0

Views: 14621

Answers (4)

user11442718
user11442718

Reputation:

The only available solution close to C include headers is to add a module with all your declares and shared variables.

For example:

Public variable1, variable2 as string... Declare Function X alias Y...

Upvotes: 0

MarkJ
MarkJ

Reputation: 30398

Comments indicate that you are trying to share a variable between all modules. Just declare a Public variable in a .bas module:

Public foo As String 

And, by the way, VB6 is totally different from C.

Upvotes: 2

nd.
nd.

Reputation: 8932

You don't. The purpose of header files in C is to declare (function) prototypes for libraries that you use.

  1. If your C function is available as a COM component (OCX), then you can use the OCX as an external component.

  2. In classic Visual Basic (up to 6.0) you can declare dependencies to external libraries if those libraries reside inside DLLs. For this you must use the declare feature of Visual Basic. This is basically the Visual Basic variant of the prototype used in the .h file. You must manually convert the C prototypes you want to use from the .h file to VB syntax: e.g. the C prototype BOOL foo(LPCSTR lpString, HWND hWnd) becomes Declare Function foo Lib "a.dll" (ByVal lpString As String, ByVal hwnd As Long) As Long

  3. If your C functionality is a static libary (.lib), then you cannot use this libary directly. Instead, you must create a DLL or OCX out of it (using C), and use one of the above VB features for external dependencies.

Upvotes: 1

Binil
Binil

Reputation: 6583

Goto

Menu -> Projects -> Components

and choose from the list of Components available

or for adding references

Menu -> Projects -> References

and choose from the list of References available

and call/declare it like

Dim comp as YourComponent

Upvotes: 0

Related Questions