open a new Form

  • Thread starter Thread starter Stephan Unger
  • Start date Start date
S

Stephan Unger

Hi all,


i want to open a new Form in my VB.NET Application. How can i do this when i
want to add a paramter?

i know the code:

frmxxx.showdialog() or frmxxx.show

but how can i add paramter for this new form?

thx for help
 
Hi Stephan,

Add a constructor to your Form which takes a parameter.

Class MyForm
Private TheParameter As Something
Public Sub New (ThisValue As Something)
TheParameter = ThisValue
End Sub
: : :
End Class

Then pass in the value when you create the Form - and when Show is called,
it will be available.

Dim frmxxx As MyForm
: : :
frmxxx = New MyForm (WhateverValue)
frmxxx.Show
Or
Dim frmxxx As New MyForm (WhateverValue)
frmxxx.Show

Regards,
Fergus
 
* "Stephan Unger said:
i want to open a new Form in my VB.NET Application. How can i do this when i
want to add a paramter?

i know the code:

frmxxx.showdialog() or frmxxx.show

but how can i add paramter for this new form?

\\\
Public Class ...
Inherits ...

Private m_UserName As String

Public Property UserName() As String
Get
Return m_UserName
End Get
Set(ByVal Value As String)
m_UserName = Value
End Set
End Property

' Change Me.UserName here.
End Class
///

Usage:

\\\
Dim f As New Form1()
f.UserName = "Max Mustermann"
f.ShowDialog()
MsgBox(f.UserName)
///
 
Hi Herfried,

LOL. I can't believe that you didn't notice that the query was answered
<and> the guy had said thanks and gone his merry way - 9 hours ago!!

Who are you talking to? ;-))

Regards,
Fergus
 
* "Fergus Cooney said:
LOL. I can't believe that you didn't notice that the query was answered
<and> the guy had said thanks and gone his merry way - 9 hours ago!!

Who are you talking to? ;-))

Sorry, for some unknown reason I cannot see the other replies...
 
Hi Herfried,

That doesn't sound like good gnus. You've been ham(ster)strung by the
sound of it!

Regards,
Fergus

** Loud groans encouraged - permission to hit me granted ;-)
 
* "Fergus Cooney said:
That doesn't sound like good gnus. You've been ham(ster)strung by the
sound of it!

I have changed some options in the newsreader and the posts are visible
now...

;-)
 
Back
Top