Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2006
    Posts
    47

    Unanswered: Instatiating a class with defualt params

    I created a class trade and added all my public and private items

    i would like the constructor to take 5 params, like :

    dim t as new trade(Parm1,Parm2,Parm3)

    is this possible with VBA?

  2. #2
    Join Date
    Jun 2006
    Location
    Colton, CA
    Posts
    26
    Yes, in your class module do something like this

    Code:
    Public Sub Trade(param1 as string, param2 as string, param3 as string) As String
    ' we use sub instead of function as we're not looking for a return value
    end sub
    Geek it till it mHz

  3. #3
    Join Date
    Jun 2006
    Posts
    103
    Quote Originally Posted by spikey_richie
    Yes, in your class module do something like this

    Code:
    Public Sub Trade(param1 as string, param2 as string, param3 as string) As String
    ' we use sub instead of function as we're not looking for a return value
    end sub

    but you are looking for a return value which is String. I bet this will cause an error

  4. #4
    Join Date
    Jun 2006
    Location
    Colton, CA
    Posts
    26
    Why not just say "remove the As String from the end as it'll cause an error"?
    Geek it till it mHz

  5. #5
    Join Date
    Apr 2006
    Posts
    47
    actualy i am returning an object representing a stock exchange trade, so i will be seting a ref to the obj then using some of its functions & Properties


    dim msft as new trade(Shares,price, commishion, purchdate)

    msgbox "You now own " & msft.Shares & " Shares of Microsoft"

Posting Permissions

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