Results 1 to 3 of 3

Thread: Passing data types to functions?

  1. #1

    Thread Starter
    New Member Son of Makuta's Avatar
    Join Date
    Sep 2007

    Passing data types to functions?

    How do you give a data type to a function without specifying what type it is? I'm using data types as 'objects' of a sort to take the place of image controls, so I can have a slew of sprite-controlling variables in one place, and I'm now revamping my game to include BitBlt (or hopefully DirectX, if I can make it work ) instead of image controls. Without the image controls, all of a sudden all my collision functions and stuff don't work.

    I've tried As Variant, As Data, As Data Object and a couple of other things that looked plausible (yes, I went through that list thing). Most of it just gives type mismatches. Variant throws an error along the lines of I can only pass user defined types into a variant if they're from a "public object module". They're in a module, but how to make that a public object module I have no idea...

  2. #2
    Frenzied Member
    Join Date
    Oct 2003

    Re: Passing data types to functions?

    vb Code:
    1. Type TheType
    2.     A As Byte
    3. End Type
    5. Function ThatUsesTheType(TheArgument As TheType) As TheType
    6.     ThatUsesTheType.A = TheArgument.A
    7. End Function
    9. 'use it like:
    10. Dim X As TheType
    11. Dim Y As TheType
    13. Y = ThatUsesTheType(X)
    Do keep in mind that the function must be able to 'see' the declaration of the type.
    So it must either be declared Public or within the same module as the function.

  3. #3
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Victoria, Australia

    Re: Passing data types to functions?

    As Any.


    Visual Studio 6, Visual Studio.NET 2005, MASM

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