
-----------------------------------
GlobeTrotter
Tue Nov 29, 2005 8:39 pm

Opening a Form With Arguments
-----------------------------------
Basically, my first form is a settings form where information about the number, and type of players is entered.  The next form is the game form.  I store player info in a flexible array of a public type.  How can I pass this array of players from the settings form to the game form.  I'd like to avoid using Global variables, if possible, as they are 'apparently' bas coding practice.

I tried this type of thing: 

Settings Form:
Option Explicit

Dim Player() As GamePlayer

Public Sub StartGame
    Call frmGame.InitGame(Player)
    Me.Show
End Sub

Game Form:
note- the code inside the procedure is kind of pseudo-code.

Option Explicit

Dim Player() As GamePlayer

Public Sub InitGame(TempPlayers() As GamePlayer)
    Player = TempPlayers
    Me.Show
End Sub



I get the following error:

Compile Error:

Only public user defined types defined in public object modules can be used as parameters or return types for public procedures of class modules or as fields of public user defined types

I don't really understand it.  I declared my GamePlayer record as a public type in a seperate module.

If I am going about this all wrong, please let me know also.

-----------------------------------
pavol
Wed Nov 30, 2005 8:22 am


-----------------------------------
if you already declared your GamePlayer record in the module why don't you make it easier on yourself and just declare your array there instead of trying to declare a public record and sending a private variable to it.

I think this error is just telling you that you can't use a public types or procedures and give them a 'non-public' parameter.

-----------------------------------
Brightguy
Sat Dec 03, 2005 4:05 pm

Re: Opening a Form With Arguments
-----------------------------------
The rule is... public procedures cannot return or have user-defined types for parameters.  (Even if the user-defined type is public.)

You could do it by individually passing all the variables in your udt, but it'll be easier to just use a public variable.
