Send variable through to new form

banks

Well-known member
Joined
Sep 7, 2005
Messages
50
Programming Experience
Beginner
Now before anyone says anything, i have searched the other posts on this site but i still can't get what i'm trying to do to work, so i have to post my particular problem!

I cannot get a variable i have set in frmLoginScreen to pass through to my mdi form. I have tried the following methods -

Get/set
in frmLoginscreen where the variable intRoleID is set. (It is public)
VB.NET:
[size=2][/size][size=2][color=#0000ff]Public[/color][/size][size=2] [/size][size=2][color=#0000ff]Property[/color][/size][size=2] RoleID() [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer

[/color][/size][size=2][/size][size=2][color=#0000ff]Get

[/color][/size][size=2][/size][size=2][color=#0000ff]Return[/color][/size][size=2] intRoleID

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Get

[/color][/size][size=2][/size][size=2][color=#0000ff]Set[/color][/size][size=2]([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] value [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size][size=2])

intRoleID = value

[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Set

[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Property

End[/color][/size][size=2] [/size][size=2][color=#0000ff]Class

[/color][/size]

In the mdi...
VB.NET:
[size=2][color=#0000ff]Public[/color][/size][size=2] login [/size][size=2][color=#0000ff]As[/color][/size][size=2] frmLoginScreen()[/size]
[size=2][/size] 
[size=2][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] intRoleID [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Integer[/color][/size]
[size=2][color=#0000ff]Dim[/color][/size][size=2] alex = [/size][size=2][color=#0000ff]New[/color][/size][size=2] frmLoginScreen[/size]
[size=2]alex.RoeID = intRoleID[/size]
[size=2][/size] 
[size=2]
[/size]

I have also tried referencinghe form and the variable i.e. frmLoginscreen.intRoleid = etc, but this doesn't wotk and i dont belive this is the way it should be done in .net.

I have also played with the constructor in frmLoginScreen for the mdi, but am not sure of how to pass the variable through

VB.NET:
[size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] mdiMTSM [/size][size=2][color=#0000ff]As[/color][/size][size=2] mdiMTSM = [/size][size=2][color=#0000ff]New[/color][/size][size=2] mdiMTSM

mdiMTSM.ShowDialog()

[/size]

Any help is extemlely appreciated,

Kind Regards,

Alex[/size]
 
Hey,

I'm not altogether sure how you've got this structured so I might be wrong here but generally speaking.

say you were passing to mdiMTSM from frmLogin --- set up the property in mdiMTSM:

in mdiMTSM:
VB.NET:
dim RoleID as Integer
 
Public property MyRoleID as integer
 
Get
return RoleID
End Get
[color=#0000ff]
Set[/color]([color=#0000ff]ByVal[/color] Value [color=#0000ff]As[/color] [color=#0000ff]Integer[/color])
RoleID = Value
[color=#0000ff]End[/color] [color=#0000ff]Set
[/color]
End Property

Then in frmLoginScreen:

VB.NET:
[color=#0000ff]Dim[/color][size=2] mdiMTSM [/size][size=2][color=#0000ff]As[/color][/size][size=2] mdiMTSM = [/size][size=2][color=#0000ff]New[/color][/size][size=2] mdiMTSM
mdiMTSM.MyRoleID = X[/size]
[size=2]mdiMTSM.ShowDialog()
[/size]
 
Thanks for your reply,

I have put this code in and it all looks great, but what i'm finding is that roleid is not being populated with the value i set in frmLoginScreen. Is there something i need to do to get the property myroleid to initiate? I am sure that in the login form, i am putting a value into mdiMTSM.myRoleID.

Any help much apreciated,

Alex
 
Back
Top