Calculate inside textbox

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

Calculate inside textbox

Post by ALD Automotive »

Hello,
Is is possible calculate inside textbox?
Examlpe:
  1. $a = $textbox1.text
  2. $b=$textbox2.text
  3. $result= $a+$b
  4. $resultTextbox.text = $result
If i wtite at textbox1 - "5" and textbox2 - "5" as result i receive "10"
But i want write at textbox1 "5+1" and textbox2 - "5" and as result receive "11"
Is it possible?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Calculate inside textbox

Post by jvierra »

It is possible to evaluate a string.

$s = '5 * 2 + 3'
Invoke-Expression $s
User avatar
ALD Automotive
Posts: 11
Last visit: Thu Jun 01, 2023 4:52 am

Re: Calculate inside textbox

Post by ALD Automotive »

Thank you very much!
This topic is 6 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked