|
-
Dec 30th, 2011, 05:42 PM
#1
Thread Starter
New Member
Porting a function from vb.NET to VB6
Hello, I have a particular OCX that I want to control under vb6, the structure of the OCX is as follows:
Nameofheocx.AssignValue (var as String, val as String)
And the way I use it in vb.NET is as follows
Code:
Tele2Ctrl.AssignValue("name of variable", "text")
That works under vb.NET, but in vb6 it gives out sintax error, I believe because vb6 does not accept two strings in the OCX call, other methods of the OCX that only use one string, work OK in vb6, like the following:
Code:
Tele2Ctrl.LoadLogosAndProfiles ("c:\alphapro\Profiles.XML")
The above works both in vb6 an in vb.NET.
So, the problem in vb6 appears when I try to put two strings separated with a comma to be passed to the OCX.
Any Idea how can I pass two strings to my ocx in vb6 like I do in vb.NET
Thanks for your help.
-
Dec 30th, 2011, 05:46 PM
#2
Re: Porting a function from vb.NET to VB6
You can reference and add that ocx to your form? If so,
1) In design view, press F2
2) In the top left combobox, find that ocx & select it
3) In the next combobox, enter AssignValue and then click binoculars button
4) Find AssignValue in the upper listview & select it
5) At the very bottom of the window now, you'll see a declaration for the property
Can you copy & paste that here so we can see it too?
-
Dec 30th, 2011, 05:52 PM
#3
Thread Starter
New Member
Re: Porting a function from vb.NET to VB6
Here you have:
Code:
Sub AssignValue(var As String, val As String)
Miembro de TELE2CTRLLib.Tele2Ctrl
method AssignValue
Thanks.
-
Dec 30th, 2011, 06:04 PM
#4
Re: Porting a function from vb.NET to VB6
Ok, try 1 of these 2; should be same result if it works
1) remove the parentheses
2) precede that statement with the word: Call
-
Dec 30th, 2011, 06:19 PM
#5
Thread Starter
New Member
Re: Porting a function from vb.NET to VB6
 Originally Posted by LaVolpe
Ok, try 1 of these 2; should be same result if it works
1) remove the parentheses
2) precede that statement with the word: Call
Yes, indeed, both solutions worked I am a happy man, thanks very much for your help.
Any explanation why it has to be formatted this way ?
Regards.
-
Dec 30th, 2011, 06:35 PM
#6
Re: Porting a function from vb.NET to VB6
Unlike .Net, VB has a tendency to pass what is in parentheses as an evaluated expression, when not assigning a value to the return or in the case of subroutines. If it can't be evaluated -- syntax error. If no value will be returned, then one of the following is preferred
a) Call SomeSub(lparam, wparam)
b) SomeSub lparam, wparam
Edited: same with a function. If you don't need nor care about the function's return value, then a function can be called the same as subroutine described above.
Last edited by LaVolpe; Dec 30th, 2011 at 06:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|