Results 1 to 6 of 6

Thread: Porting a function from vb.NET to VB6

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    4

    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.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    4

    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.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2011
    Posts
    4

    Thumbs up Re: Porting a function from vb.NET to VB6

    Quote Originally Posted by LaVolpe View Post
    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.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    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.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width