locked
Form textbox values RRS feed

  • Question

  • Hello

    I'm a forms noob

    I have a form that I lookup machine information by selecting the machine from a combobox.  This works fine.

    However, I now want to add a textbox for an IP address (to lookup machine information based on an IP).  I can't seem to figure out how Im going to check the combobox to see if there is a value selected.

    Im trying If($Inputbox) { .... }  but I can't seem to figure out if it there is no item selected, then take the value in the Textbox ($IPInput).

    When using the $Inputbox - hostname of the computer, it's value is put into a variable called $Hostname, then all the information gathered references $Hostname.  However, if it is to lookup using the IP, I need $Hostname's value to be $IPInput's value.  Otherwise I would need to code all the info lookups twice.

    Any suggestions?  I know Im not the only one to have this scenario at one point or another :)

    Thank You

    Terry

    Friday, February 15, 2019 9:26 PM

Answers

  • You are using -eq where you should be using "=".

    I suggest you learn PowerShell before you try to create forms.


    \_(ツ)_/

    • Marked as answer by terryvanduzee Tuesday, February 19, 2019 7:07 PM
    Tuesday, February 19, 2019 6:59 PM

All replies

  • You would use the "SelectedItem"  of the ComboBox control to find its value.

    You would use the "Text" property of a TextBox control to get its value.

    Here are the docs and examples of how to use most controls: https://info.sapien.com/index.php/guis/gui-controls

    You can also search for the control documentation by control name on MSDN.


    \_(ツ)_/


    • Edited by jrv Friday, February 15, 2019 9:59 PM
    Friday, February 15, 2019 9:58 PM
  • Thank you for the reply.

    I have most of it working, however, I can't get the variable to change based on what is selected.

    In my form I have a group (group 1).  In the group, I have 2 radiobuttons (radiobutton1 and radiobutton2).

    What I am doing is looking up computer info based on the value of either radiobutton1 or radiobutton2.

    I'm using:

    $outputBox.Text = ""  #clears any text in the results box
    If($RadioButton1.checked) 
    {
    $Hostname -eq $InputBox.SelectedItem
    }
    Else {
    $Hostname -eq $IPInput.Text}
    

    However, if I select a value from the combobox, then after I do the lookup, I change the radiobutton to radiobutton2 (lookup by IP rather than by hostname), it does not substitute the hostname with the IP ($hostname is the variable name for the lookup).

    Not sure if it's worth mentioning, but on my radiobutton click, I disable the either the textbox or the combobox depending on which is clicked.

    Thank You

    Terry

    Tuesday, February 19, 2019 6:48 PM
  • You are using -eq where you should be using "=".

    I suggest you learn PowerShell before you try to create forms.


    \_(ツ)_/

    • Marked as answer by terryvanduzee Tuesday, February 19, 2019 7:07 PM
    Tuesday, February 19, 2019 6:59 PM
  • Thank You so much.. that's what it was.

    I am attempting to learn both at the same time, because I have a need for both.

    I am one who learns by doing examples of what I need to do.

    Again, Thank You so much

    Terry

    Tuesday, February 19, 2019 7:07 PM
  • You cannot learn either correctly solely from examples.

    See this thread for more information that will help you understand how to proceed: https://social.technet.microsoft.com/Forums/windowsserver/en-US/19fc67e2-19b1-4162-a902-dcde0a07e17e/powershell-forms-textbox-input-check-forward-content-to-a-new-form?forum=winserverpowershell


    \_(ツ)_/

    Tuesday, February 19, 2019 7:11 PM