vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Blitzschnelles Erstellen von grafischen Diagrammen!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Immer Wiederkehrenden Code kürzen? 
Autor: blueberlin
Datum: 29.10.23 19:31

Hallo,

Ich habe ein sehr Simplen Quellcode für ein Spiel was ich gerade Bastel.

Der Code ist immer der selbe, leider komme ich auf keine Lösung wie ich ihn kürzen kann.

Meine Idee mit

if Label2.Text="Feld" then Hauptfenster.PictureBox(Label3.Text).Visible = False
wäre sicherlich schön gewesen, klappt aber leider nicht.

Habt ihr ein Tipp für mich wie ich da am besten rangehe?

If Label2.Text = "Feld" And Label3.Text = "1" Then _
  Hauptfenster.PictureBox1.Visible = False
If Label2.Text = "Feld" And Label3.Text = "2" Then _
Hauptfenster.PictureBox2.Visible = False
If Label2.Text = "Feld" And Label3.Text = "3" Then _
Hauptfenster.PictureBox3.Visible = False
If Label2.Text = "Feld" And Label3.Text = "4" Then _
Hauptfenster.PictureBox4.Visible = False
If Label2.Text = "Feld" And Label3.Text = "5" Then _
Hauptfenster.PictureBox5.Visible = False
If Label2.Text = "Feld" And Label3.Text = "6" Then _
Hauptfenster.PictureBox6.Visible = False
If Label2.Text = "Feld" And Label3.Text = "7" Then _
Hauptfenster.PictureBox7.Visible = False
If Label2.Text = "Feld" And Label3.Text = "8" Then _
Hauptfenster.PictureBox8.Visible = False
If Label2.Text = "Feld" And Label3.Text = "9" Then _
Hauptfenster.PictureBox9.Visible = False
If Label2.Text = "Feld" And Label3.Text = "10" Then _
Hauptfenster.PictureBox10.Visible = False
If Label2.Text = "Feld" And Label3.Text = "11" Then _
Hauptfenster.PictureBox11.Visible = False
If Label2.Text = "Feld" And Label3.Text = "12" Then _
Hauptfenster.PictureBox12.Visible = False
If Label2.Text = "Feld" And Label3.Text = "13" Then _
Hauptfenster.PictureBox13.Visible = False
If Label2.Text = "Feld" And Label3.Text = "14" Then _
Hauptfenster.PictureBox14.Visible = False
If Label2.Text = "Feld" And Label3.Text = "15" Then _
Hauptfenster.PictureBox15.Visible = False
If Label2.Text = "Feld" And Label3.Text = "16" Then _
Hauptfenster.PictureBox16.Visible = False
If Label2.Text = "Feld" And Label3.Text = "17" Then _
Hauptfenster.PictureBox17.Visible = False
If Label2.Text = "Feld" And Label3.Text = "18" Then _
Hauptfenster.PictureBox18.Visible = False
If Label2.Text = "Feld" And Label3.Text = "19" Then _
Hauptfenster.PictureBox19.Visible = False
If Label2.Text = "Feld" And Label3.Text = "20" Then _
Hauptfenster.PictureBox20.Visible = False
If Label2.Text = "Feld" And Label3.Text = "21" Then _
Hauptfenster.PictureBox21.Visible = False
If Label2.Text = "Feld" And Label3.Text = "22" Then _
Hauptfenster.PictureBox22.Visible = False
If Label2.Text = "Feld" And Label3.Text = "23" Then _
Hauptfenster.PictureBox23.Visible = False
If Label2.Text = "Feld" And Label3.Text = "24" Then _
Hauptfenster.PictureBox24.Visible = False
If Label2.Text = "Feld" And Label3.Text = "25" Then _
Hauptfenster.PictureBox25.Visible = False
If Label2.Text = "Feld" And Label3.Text = "26" Then _
Hauptfenster.PictureBox26.Visible = False
If Label2.Text = "Feld" And Label3.Text = "27" Then _
Hauptfenster.PictureBox27.Visible = False
If Label2.Text = "Feld" And Label3.Text = "28" Then _
Hauptfenster.PictureBox28.Visible = False
If Label2.Text = "Feld" And Label3.Text = "29" Then _
Hauptfenster.PictureBox29.Visible = False
If Label2.Text = "Feld" And Label3.Text = "30" Then _
Hauptfenster.PictureBox30.Visible = False
If Label2.Text = "Feld" And Label3.Text = "31" Then _
Hauptfenster.PictureBox31.Visible = False
If Label2.Text = "Feld" And Label3.Text = "32" Then _
Hauptfenster.PictureBox32.Visible = False
If Label2.Text = "Feld" And Label3.Text = "33" Then _
Hauptfenster.PictureBox33.Visible = False
If Label2.Text = "Feld" And Label3.Text = "34" Then _
Hauptfenster.PictureBox34.Visible = False
If Label2.Text = "Feld" And Label3.Text = "35" Then _
Hauptfenster.PictureBox35.Visible = False
If Label2.Text = "Feld" And Label3.Text = "36" Then _
Hauptfenster.PictureBox36.Visible = False
If Label2.Text = "Feld" And Label3.Text = "37" Then _
Hauptfenster.PictureBox37.Visible = False
If Label2.Text = "Feld" And Label3.Text = "38" Then _
Hauptfenster.PictureBox38.Visible = False
If Label2.Text = "Feld" And Label3.Text = "39" Then _
Hauptfenster.PictureBox39.Visible = False
If Label2.Text = "Feld" And Label3.Text = "40" Then _
Hauptfenster.PictureBox40.Visible = False
If Label2.Text = "Feld" And Label3.Text = "41" Then _
Hauptfenster.PictureBox41.Visible = False
If Label2.Text = "Feld" And Label3.Text = "42" Then _
Hauptfenster.PictureBox42.Visible = False
If Label2.Text = "Feld" And Label3.Text = "43" Then _
Hauptfenster.PictureBox43.Visible = False
If Label2.Text = "Feld" And Label3.Text = "44" Then _
Hauptfenster.PictureBox44.Visible = False
If Label2.Text = "Feld" And Label3.Text = "45" Then _
Hauptfenster.PictureBox45.Visible = False
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Immer Wiederkehrenden Code kürzen?206blueberlin29.10.23 19:31
Re: Immer Wiederkehrenden Code kürzen?99Manfred X29.10.23 20:43
Re: Immer Wiederkehrenden Code kürzen?83blueberlin29.10.23 21:01
Re: Immer Wiederkehrenden Code kürzen?91Kuno6029.10.23 21:13
Re: Immer Wiederkehrenden Code kürzen?84Manfred X29.10.23 21:32

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel