0

I have a PowerShell file, say TestForm.ps1 and a PrimalForm file, UserForm.ps1, with 3 textboxes; as in the following code:

$FormPath = $PSScriptRoot + "\UserForm.ps1"
$Result = & $FormPath

I don't know, how to read the text entered in the 3 textboxes of the UserForm.ps1 into my calling TestForm.ps1.

Please help.

1 Answer 1

1

One way is to modify the code PrimalForm generates to return a value from it's GenerateForm function.

#Generated Form Function
function GenerateForm {
########################################################################
# Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.9.0
# Generated On: 8/8/2011 2:30 PM
# Generated By: Andy Arismendi
########################################################################

# ... bunch of generated code ...

#Show the Form
$your_form.ShowDialog()| Out-Null

$text_box_values = @{}
$text_box_values.a = $text_box_1.Text
$text_box_values.b = $text_box_2.Text
$text_box_values.c = $text_box_3.Text

return $text_box_values

} #End Function

This little example will return a hash table with keys a,b and c which store the text box values.

Sign up to request clarification or add additional context in comments.

1 Comment

It seems exactly, what I want. Let me try it. Thank you very much for your attention and regards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.