Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 6th, 2003, 08:15 AM
Dan Burke Dan Burke is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Davenport, IA
Posts: 3 Dan Burke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Need help applying C dll's in VB6

I am having a devil of time calling a "C" dll from VB6. The "C" function was created in Visual Studio, same for the VB6. Does anyone have a sample "C" project, etc. that can help?

Dan

Errors range from "file not found" to "bad calling convention", with an occasional "can't find dll entry point" thrown in for good measure.Dan

Reply With Quote
  #2  
Old August 6th, 2003, 08:21 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
How are you trying to call the dll function in vb?

Reply With Quote
  #3  
Old August 6th, 2003, 08:52 AM
Dan Burke Dan Burke is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Davenport, IA
Posts: 3 Dan Burke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have tried both byVal and byRef in separate *.cpp's of course.
The errors "file not..." an "can't find entry..." i believe a can fix. BUT the "bad calling..." error has me stumped...

Reply With Quote
  #4  
Old August 6th, 2003, 09:34 AM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,834 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 23 h 30 m 30 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
how are you declaring the function in the vb code

Reply With Quote
  #5  
Old August 6th, 2003, 09:55 AM
Dan Burke Dan Burke is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Davenport, IA
Posts: 3 Dan Burke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How much can I stuff in this little box..?? Note that "interp" is a subroutine.

Here the first few lines of the VB..

Option Base 1 ' sets the array index to 1
/
Declare Sub interp Lib "E:\Simulations\Current\interpolation_v0b.dll" (ByRef inputTemp As Double, ByRef inputAtmPres As Double, ByRef inputPres As Double, ByRef inputPrdFlow As Double, ByRef ProdPurity As Double, ByRef AirConsump As Double, ByRef PressDrop As Double, ByRef PermPurity As Double)
/
Sub Test()
'
Dim inputTemp As Double ' Input Temp
Dim inputAtmPres As Double ' Input Atm Pres
Dim inputPres As Double ' Input Inlet Pres
.
.
Call interp(inputTemp, inputAtmPres, inputPres, inputPrdFlow, ProdPurity, AirConsump, PressDrop, PermPurity)
.
.
.
.

And here are the first few lines of the *.cpp


// interpolation_v0b.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"

extern "C" __declspec(dllexport) void interp(double &t,double &ap,double &ip,double &f,
double &o2,double &ac,double &dp,double &po2);

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
.
.
.
.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Need help applying C dll's in VB6


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway