Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

Powershell 4.0 Ausgabe

$
0
0

Hey Leute,

ich habe jetzt schon echt lange gesucht und auch viel probiert. Wahrscheinlich ist es auch nur eine Kleinigkeit, aber ich komme einfach nicht drauf.

Aufgabe ist: Erstelle via Powershell eine Grid Ausgabe mit Eingabe Feld. Gebe hier den Ländercode ein und lass dir das jeweilige Land ausgeben. Nach jeder Ausgabe soll das Programm so lang weiterarbeiten bis auf Cancel geklickt wird. Angelegt ist eine countrycode.txt die wie folgt gelistet ist:

Name,Iso

Albania,AL

Austria,AU

usw.

getrennt durch Kommas für die einzelnen Spalten.

Meine Ausgabe für ein Land funktioniert schon, nur ist hier das Problem das er eben alles ausgiebt in dem z.b. ein AL enthalten ist. D.h. er sucht nicht expliziert in der Reihe "ISO" ich weiß in meinem Code ist auch jetzt nichts definiert, hab es schon über diverse IF abfragen versucht aber komme damit nicht hin.

Hier mal mein Code:

[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Drawing”)
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = “Ländercode Suche”
$objForm.Size = New-Object System.Drawing.Size(400,300)
$objForm.StartPosition = “CenterScreen”
$objForm.KeyPreview = $True
$objForm.Add_KeyDown({if ($_.KeyCode -eq “Enter”){$output}})
$objForm.Add_KeyDown({if ($_.KeyCode -eq “Escape”)  {$objForm.Close()}})

$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = “OK”
$OKButton.DialogResult = “OK”
$OKButton.Add_Click({$output})
$objForm.Controls.Add($OKButton)

$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = “Cancel”
$CancelButton.DialogResult = “Cancel”
$CancelButton.Add_Click({$objForm.Close()})
$objForm.Controls.Add($CancelButton)

$objLabel = New-Object System.Windows.Forms.Label
$objLabel.Location = New-Object System.Drawing.Size(10,20)
$objLabel.Size = New-Object System.Drawing.Size(280,20)
$objLabel.Text = “Bitte geben Sie den Ländercode ein:”
$objForm.Controls.Add($objLabel)

$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,40)
$objTextBox.Size = New-Object System.Drawing.Size(260,20)
$objForm.Controls.Add($objTextBox)

$objForm.Topmost = $True
$objForm.Add_Shown({$objForm.Activate()})

[void] $objForm.ShowDialog()
$output = new-object System.Windows.forms.label
$output.location = new-object System.drawing.size(30, 200)
$output.size = New-Object System.Drawing.Size(300,300)
$output.Text =Import-Csv "c:\Users\oziegler\Desktop\CC\countrycode.txt"         |                    Select-string $objTextBox.text
$objform.controls.add($output)



[void] $objForm.ShowDialog()
$output.text

Habt ihr da noch eine Idee? Schonmal vielen Dank im Voraus.

Vielen Dank im Voraus =)


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>