Marco said:
That's what I've been doing up until now but I was hopping that there was a
better way to do it. Oh well, stick with what works I guess. Thanks.
Jim's solution isn't so bad
One nicety might be to make the method that's called a *Shared* method
(like MessageBox.Show is), so that the caller doesn't have to worry
about the details of instantiation.
this code is untried and might not even compile:
Class MyDialogBox
Inherits Form
'the form has a label control and a text box control on it
'and an ok button
Public Shared Function GetAnswer(byval Caption as string) as string
Dim box as new MyDialogBox()
box.Caption = Caption
Return box.Answer
'box will get tidied up automatically
End Function
Private _answer as string=""
Public Function Answer() As string
Me.ShowDialog
Return _answer
End Function
Public Property Caption as string
'(Code omitted: caption <-> label1.text)
private sub Textbox1_Changed('etc
_answer = Textbox1.Text
end sub
private sub Button1_Clicked('etc
Me.Hide
end sub
End Class
To use:
Dim TheAnswer As String = MyDialogBox.GetAnswer("What's the meaning of
life etc")