CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2005
    Posts
    95

    public object modules?

    Hello I set up a "type", included in my .bas module...seems to work fine:

    Code:
    Public Type DynaData
     FramePar As Integer
     VIndex As Integer
     EEPloc As Integer
     NoRespOK As Boolean
    End Type
    In my main form General Declarations I do:
    Code:
    Dim RadBut(200) As DynaData
    I use this without problem in various routines & various calculations. However I need to pass this type to a sub (as well as similar types to the same sub, which is why I want to create a sub in the first place)

    Code:
    call MYSub(123, RadBut() )    'should it be plain RadBut or RadBut()?
    such as:
    Code:
      Public Sub MySub(intAbc as Integer, FakeType as DynaData)
    ...however here it gives a compiler error saying
    "only public user defined types defined in public object modules can be used as parameters..... "

    Ok so where should I put my type definition (what IS a public object module?) or how do I make one of my private modules public?
    Last edited by vbcandies; January 2nd, 2010 at 03:14 AM.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: public object modules?


  3. #3
    Join Date
    Dec 2001
    Posts
    6,332

    Re: public object modules?

    Where are you trying to put the Public Sub?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  4. #4
    Join Date
    Nov 2005
    Posts
    95

    Re: public object modules?

    Where are you trying to put the Public Sub? ...in my "program" That is, I click on the form, and that is where all of my other code is located.
    Where should I place my Type definition? Any example would be helpful

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: public object modules?

    If you want to pass a complete array to a sub you have to declare your parameter accordingly:
    Code:
    Public Sub MySub(intAbc as Integer, FakeType() as DynaData)
    'This allows later
    MySub 5, RadBut
    'or
    Call MySub(5, RadBut)
    'which is the same
    Last edited by WoF; January 4th, 2010 at 09:29 AM. Reason: corrected a typo with the brackets

  6. #6
    Join Date
    Dec 2001
    Posts
    6,332

    Re: public object modules?

    If you move the Public Sub (declared as WoF suggests) to the .bas module, it should work. Then you can call the sub from any form in your program.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  7. #7
    Join Date
    Nov 2005
    Posts
    95

    Re: public object modules?

    I changed the type of sub I was having trouble with from public to private & POOF ...all the compiler errors went away & it works just fine!

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

Featured