markus2016
Goto Top

While Schleife mit mehreren Arrays

Hallo zusammen,

habe Probleme mit der Schleife und komme gerade einfach nicht drauf wo der Fehler liegt.

$i=0

Do{
$I_InfoBox = New-Object System.Windows.Forms.Label
$I_InfoBox.Location = New-Object System.Drawing.Size($I_InfoBox_Location[$i]) 
$I_InfoBox.Size = New-Object System.Drawing.Size($I_InfoBox_Size)
$I_InfoBox.Font = $I_Schrift 
$I_InfoBox.Text = $I_InfoBox_Text[$i]
$Global:Window.Controls.Add($I_InfoBox) 

$I_TextBox = New-Object System.Windows.Forms.TextBox 
$I_TextBox.Location = New-Object System.Drawing.Size($I_TextBox_Location[$i]) 
$I_TextBox.Size = New-Object System.Drawing.Size($I_TextBox_Size)
$I_TextBox.Font = $I_Schrift
$I_TextBox.Text = $Global:I_TextBox_Text[$i] 
$Global:Window.Controls.Add($I_TextBox) 

$i++ 
}
while ($i -lt $I_InfoBox_Location.Length); &$I_InfoBox_Text.Length; &$I_TextBox_Location.Length; &$Global:I_TextBox_Text.Length

Die Konsole gibt jeweils zur letzten Array folgenden Fehler aus:

& : Die Benennung "7" wurde nicht als Name eines Cmdlet, einer Funktion, einer Skriptdatei oder eines ausführbaren
Programms erkannt. Überprüfen Sie die Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und
wiederholen Sie den Vorgang.
In C:\Windows_Home\Windows-Image erstellen\Windows-Image erstellen-18.09.ps1:146 Zeichen:45

back-to-top... ($i -lt $I_InfoBox_Location.Length); &$I_InfoBox_Text.Length; &$I_Te ...

back-to-top~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : ObjectNotFound: (7:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Vielen Dank für Eure Unterstützung

Schöne Grüße

Markus2016

Content-Key: 315623

Url: https://administrator.de/contentid/315623

Printed on: April 23, 2024 at 07:04 o'clock

Mitglied: 129813
Solution 129813 Sep 19, 2016 updated at 06:19:32 (UTC)
Goto Top
Hi,
& is an execution operator no comparison operator! If you want to combine conditions use the -and or -or operator
#...
} while ($i -lt $I_InfoBox_Location.Length) -and $i -lt $I_InfoBox_Text.Length -and $i -lt &$I_TextBox_Location.Length -and $i -lt $Global:I_TextBox_Text.Length)

Where did you get the single & from ?? This is never used in any language to form an and condition only as doubles &&, but in PS this is no valid syntax!!!

Regards
Member: Markus2016
Markus2016 Sep 20, 2016 at 20:40:18 (UTC)
Goto Top
Hello highload,

thank you. perfekt face-smile

Markus2016