Dear Experts,can we make dll in turbo c and use that dll in vb 6.0. Actually i have a program in c and it has so many constant 3 dimensional array.I have to use some API which can not be used in turbo c so i am planning to make turbo c file dll and use this dll in vb 6.0 with API. Pardeep

Dani AI

Generated

As already pointed out, Turbo C itself is not a practical way to produce a DLL usable from VB6. Practical paths are: 1) recompile/port the C code with a 32-bit Windows compiler that can produce DLLs (for example MinGW or MSVC), or 2) avoid a DLL altogether and let VB6 read a binary data file (or resource) containing your large arrays. The rest below gives a minimal, practical approach you can apply without changing VB6 much.

Create a small, well-defined DLL wrapper in a modern 32-bit toolchain. Export simple stdcall functions (no C++ name mangling) that return scalar values or that fill a caller-allocated buffer. Example C wrapper (compile as C or use extern "C"):

#ifdef __cplusplus
extern "C" {
#endif

__declspec(dllexport) void __stdcall GetConstValue(int x, int y, int z, float *out)
{
    *out = myArray[x][y][z];
}

#ifdef __cplusplus
}
#endif

Declare and call that from VB6 with matching types and calling convention:

Private Declare Sub GetConstValue Lib "MyDll.dll" (ByVal x As Long, ByVal y As Long, ByVal z As Long, ByRef outValue As Single)

Dim v As Single
GetConstValue 1, 2, 3, v

Key practical gotchas and tips: the DLL must be 32-bit (VB6 is a 32-bit process); the calling convention must match (VB6 expects stdcall); avoid C++ name mangling (use extern "C" or a .def file); map VB types correctly (VB6 Long = 32-bit, Integer = 16-bit, Single = float); for very large arrays consider exposing a FillBuffer function that copies into a VB Byte buffer (pass ByRef buffer(0)), or ship the arrays as a binary file and read them from VB to avoid bloating the DLL. If you need rich array marshaling or automation, write an ActiveX/COM wrapper that uses SAFEARRAYs, but that is more work.

No. Turbo C (at least the version most people here seem to talk about) is a 16-bit DOS compiler, and cannot create Windows DLL files.

Frankly, you would do well to drop both Turbo C and Visual Basic 6.0 and get modern compilers for both languages (OK, so VB.Net is very different from VB 6.0, but were talking about a 15 year old compiler).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.