Как передавать значение

Программа

Button1 открывает модальное окно, чья этикетка показывает текст "modal".
Button2 открывает немодальное окно, чья этикетка показывает текст "modeless".
(Если вы не знаете разницу между модальным и немодальным окном, взгляните на Как открыть модальную форму - modal Form.)
In each case, the Text is passed as a value.

Код:

Fmain.class

PRIVATE hNew AS Fsecond

STATIC PUBLIC SUB Main()
DIM hForm AS Form
hForm = NEW Fmain
hForm.show
END

PUBLIC SUB Button1_Click()
'if the second parameter is true, the new window should be modal
  ShowSecond("modal, " & TextBox1.Text, TRUE)
END

PUBLIC SUB Button2_Click()
ShowSecond("modeless, " & TextBox1.Text, FALSE)
END

PRIVATE SUB ShowSecond(strVal AS String, bmode AS Boolean)
IF bmode THEN
'here the constructor of the class Fsecond is used
'to receive the passed value.
'have a look at Fsecond's constructor _new()!
    hNew = NEW Fsecond(strVAl)
hNew.ShowModal
ELSE
'here a method of Fsecond is used to receive the
'passed value.
    hNew = NEW Fsecond
hNew.UpdateField(strVal)
hNew.Show
ENDIF
END

Fsecond.class:


'the parameter has to be optional,
'otherwise it would be impossible to
'initialize an instance of this class
'without a parameter

PUBLIC SUB _new(OPTIONAL X AS String)
UpdateField(X)
END

PUBLIC SUB UpdateField(wort AS String)
TextLabel1.Text=wort
END