Hallo Zusammen,
ich möchte mit VBA die Zeit eines Fahrplans ausrechnen. Ich habe sieben OptionsButtons die je ein Tag und vier Checkboxen die je ein Problem darstellen. Hinter jeder dieser Buttons ist ein Wert hinterlegt.Ich habe auch schon eine Programm geschrieben nur ist es sehr aufwändig, ich hoffe Ihr könnt mir vielleicht weiter helfen, wie ich es verkürzen bzw. vereinfachen kann.Ich hoffe es findet sich jemand.
Danke
Es ist ein kleiner Ausschnitt vom ganzen Code. Ist es möglich,diese Kombinationen von Klicks anders zur formulieren, da sich dieser Abschnitt sich erst nur für den Montag bezieht.
ich möchte mit VBA die Zeit eines Fahrplans ausrechnen. Ich habe sieben OptionsButtons die je ein Tag und vier Checkboxen die je ein Problem darstellen. Hinter jeder dieser Buttons ist ein Wert hinterlegt.Ich habe auch schon eine Programm geschrieben nur ist es sehr aufwändig, ich hoffe Ihr könnt mir vielleicht weiter helfen, wie ich es verkürzen bzw. vereinfachen kann.Ich hoffe es findet sich jemand.
Danke
Es ist ein kleiner Ausschnitt vom ganzen Code. Ist es möglich,diese Kombinationen von Klicks anders zur formulieren, da sich dieser Abschnitt sich erst nur für den Montag bezieht.
VB.NET-Quellcode
- Option Explicit
- Private Sub CheckBox1_Click() 'Feiertag - a
- If OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b, TextBox1), "dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox3.Value = True And CheckBox2.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox4.Value = True And CheckBox2.Value = False And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox4.Value = True And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox3.Value = True And CheckBox4.Value = True And CheckBox2.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = True Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo, TextBox1), " dd.mm.yyyy hh:nn:ss")
- '--------
- ElseIf OptionButton1.Value = True And CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox3.Value = True And CheckBox2.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox4.Value = True And CheckBox2.Value = False And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox4.Value = True And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox3.Value = True And CheckBox4.Value = True And CheckBox1.Value = False And CheckBox2.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox1.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox3.Value = True And CheckBox2.Value = False And CheckBox1.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox4.Value = True And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox1.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True Then
- TextBox2.Text = Format$(DateAdd("n", Mo, TextBox1), " dd.mm.yyyy hh:nn:ss")
- End If
- End Sub
- Private Sub OptionButton1_Click() 'Montag
- If OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = True Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox4.Value = True And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox3.Value = True And CheckBox4.Value = True And CheckBox2.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox4.Value = True And CheckBox1.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = True And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + b, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox3.Value = True And CheckBox2.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox4.Value = True And CheckBox2.Value = False And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox3.Value = True And CheckBox1.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox4.Value = True And CheckBox1.Value = False And CheckBox3.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox3.Value = True And CheckBox4.Value = True And CheckBox1.Value = False And CheckBox2.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + c + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox1.Value = True And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + a, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox2.Value = True And CheckBox1.Value = False And CheckBox3.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + b, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox3.Value = True And CheckBox2.Value = False And CheckBox1.Value = False And CheckBox4.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + c, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True And CheckBox4.Value = True And CheckBox2.Value = False And CheckBox3.Value = False And CheckBox1.Value = False Then
- TextBox2.Text = Format$(DateAdd("n", Mo + d, TextBox1), " dd.mm.yyyy hh:nn:ss")
- ElseIf OptionButton1.Value = True Then
- TextBox2.Text = Format$(DateAdd("n", Mo, TextBox1), " dd.mm.yyyy hh:nn:ss")
- End If
- End Sub
Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von „Hamsi“ ()