Results 1 to 10 of 10

Thread: initializing Object

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    initializing Object

    This is Csharp code for initializing the Object

    Code:
    PPrivew Privew = new PPrivew( "Val1", "Val2", "Val13", "Val13","Val4" );
    how can i write this line in VB6 so that it also show me the intellisense like in Csharp

  2. #2
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Re: initializing Object

    The following should do the job of Initializing a class object using constructor

    Dim Privew As New PPrivew("Val1", "Val2", "Val13", "Val13","Val4" )

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: initializing Object

    What object are you trying to initialize? Some kind of print preview control?

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: initializing Object

    this isn't possible in VB6
    Dim Privew As New PPrivew("Val1", "Val2", "Val13", "Val13","Val4" )

    VB6 doesn't allow for alternate constructors...
    you have to do it in multi-steps:
    Code:
    Dim Privew As PPriview
    SET Priview =  New PPrivew 
    Priview.Val1 = ""
    .
    .
    .
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: initializing Object

    Yes its a print preview control

    techgnome that will not work
    vb Code:
    1. Priview.Val1 = ""

    you are setting val1 as a property
    val1 is a argument

    and that code shows error message that "invalid use of new keyword"

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: initializing Object

    And where did you get this control?

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: initializing Object

    "Some kind of print preview control?"
    "And where did you get this control?"

    is that really matters?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    120

    Re: initializing Object

    code converstion tools suggest this format
    Dim Privew As New PPrivew("Val1", "Val2", "Val13", "Val13","Val4" )
    but this is wrong
    plz help

  9. #9
    Addicted Member
    Join Date
    Mar 2008
    Posts
    143

    Re: initializing Object

    i dont think constructors exists in vb6, you have to find some alternative way to initialize your object.

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: initializing Object

    Quote Originally Posted by xor83
    Yes its a print preview control

    techgnome that will not work
    vb Code:
    1. Priview.Val1 = ""

    you are setting val1 as a property
    val1 is a argument
    I *know* that.... but you *CAN'T* use parameterized constructors in VB6. Simple as that. So that means you have to new-up the object first, THEN set the parameters, hopefully the parameters are exposed through properties of some kind.

    and that code shows error message that "invalid use of new keyword"
    That actually then answers the next question I had, which was if the object has a parameterless constructor. It does not. That essentially renders the object useless in VB6.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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