Hi,
Stanley wrote:
Hi, all! How can a show up a form then get a return string from it when
it close? I mean like inputbox! Thanks in advance
create a simple class that wraps up your query-form. I.e.:
public class frm_UserQuery
'your form-stuff goes here and should include a textbox (txtUserInput),
'a label (lblInstructions) and two buttons (OK with DialogResult.OK,
'Cancel with i.e. DialogResult.Cancel). Both buttons will close the form
end class
public class CUserQuery
public shared sub getUserInput(byval strQueryText as string) as string
dim frmQ as new new frm_UserQuery
dim strUserInput as string
frmQ.lblInstructions.text=strQueryText
frmQ.ShowDialog()
if frmQ.DialogResult = DialogResult.OK then
'User clicked the OK-button
strUserInput=txtUserInput.text
else
'User clicked the Cancel-button
strUserInput=string.empty
end if
frmQ.dispose
return strUserInput
end sub
end class
From your main form, call the above with i.e.
dim strUserInput as string = _
CUserQuery.getUserInput("Please enter something smart:")
Cheers,
Olaf