Skip to content

Instantly share code, notes, and snippets.

@codeonion
Created February 18, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeonion/d33326512d0d4837cc6c76b23a8fe5f5 to your computer and use it in GitHub Desktop.
Save codeonion/d33326512d0d4837cc6c76b23a8fe5f5 to your computer and use it in GitHub Desktop.
Powershell - Show Messagebox by condition
<# This form was created using POSHGUI.com a free online gui designer for PowerShell
.NAME
Untitled
#>
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = '400,400'
$Form.text = "Form"
$Form.TopMost = $false
$tb_payerid = New-Object system.Windows.Forms.TextBox
$tb_payerid.multiline = $false
$tb_payerid.width = 100
$tb_payerid.height = 20
$tb_payerid.location = New-Object System.Drawing.Point(135,60)
$tb_payerid.Font = 'Microsoft Sans Serif,10'
$Button1 = New-Object system.Windows.Forms.Button
$Button1.text = "button"
$Button1.width = 60
$Button1.height = 30
$Button1.location = New-Object System.Drawing.Point(161,144)
$Button1.Font = 'Microsoft Sans Serif,10'
$Form.controls.AddRange(@($tb_payerid,$Button1))
$Button1.Add_Click({ validate })
$Form.ShowDialog()
function validate(){
if($tb_payerid.Text.Length -gt 0){
[System.Windows.MessageBox]::Show('Missing Payer ID')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment