select which objects to use depending on version
Hi All,
I have a program that works alongside another program.
At the moment i have to have two seperate programs as there are two versions of the program 13 and 14 that i want it to work alongside.
Both programs i have written are exactly the same bar the dll being used (which are not backward compatible as i have tried).
Is there anyway i can determine which version i'm using and use the appropriate dll? such as an #ifdef for vb??
if so how would i use this,
so basically
if i'm runnign v13 then
Dim var As Objectv13.whatever
or if i'm running v14
Dim var As Objectv14.whatever
many thanks,
Matt.
[726 byte] By [
flynny1st] at [2007-11-20 11:41:15]

# 1 Re: select which objects to use depending on version
There is something like an #ifdef equivalent in VB, too.
It allows you conditional compilation.
You can create compiler constants and use #If to switch between different declaration segments like:
#Const Version = 14
#If Version = 14 Then
Declare Function DllFunc Lib "Dll14.dll" (Param as Long) as Long
#Else
Declare Function DllFunc Lib "Dll13.dll" (Param as Long) as Integer
#End If
#If Version = 14 Then
Dim Var as Object14
#Else
Dim Var as Object13
#End If
WoF at 2007-11-9 19:32:46 >

# 2 Re: select which objects to use depending on version
ok thats great WoF,
so how woudl i be able to determine the value of the const? would i be able to pass it in say through a command line param with ti being a const?
# 3 Re: select which objects to use depending on version
No. Seems we misunderstood. You asked for an #ifdef equivalent in VB and thats what I explained to you. It will allow conditional compiling of specific program versions. The values of a so defined #Const have direct influence at compile time and cannot be altered at runtime, const meaning constant, see?
You can pass a value to a program in the command line. The program code can get this value in Command$, being a predefined variable containing everything of the command line after the program name.
In this case you would proceed differently.
dim Version as Integer
Version = Val(Command$)
This allows to call YourProg 13 or YourProg 14
In the program you can now use normal If statements
If Version = 13 Then
Dim Var as Object13
Else
Dim Var as Object14
End If
But you made clear in your first post, you ARE running two different programs. It's a little confusing for me. To give you more specific help I must know what you actually want to achieve.
Do you want to make one program which can deal with both dlls?
Or do you want to compile two different programs one for each type of dll?
Also it would be good to know how the dlls are used within your program.
Have you declared functions? And how look these Declare statements? Are the functions the same name in both dlls?
That's all very important for being able to help you any further.
WoF at 2007-11-9 19:34:50 >
