Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1396to1400
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

HILFE D:

HILFE D:
17.12.2014 09:20:42
Fabian
Hallo,ich nochmal hab jetzt nen Quelltext geschrieben der bewirken soll,dass wenn ich in Feld 1 _ ein falschen Wert eingebe,alle anderen Felder blockiert werden bis der Wert stimmt.

Private Sub txt3b_Change()
If txt3b.Value = "B" Then
txt3b.BackColor = &HFF00&
Else: txt3b.BackColor = &HFF&: txt1d.Enabled = False: txtd1.Enabled = False: txt1r.Enabled =  _
False: txt2b.Enabled = False: txt2u.Enabled = False: txt2n.Enabled = False: txt2d.Enabled = False: txt2e.Enabled = False: txt2s.Enabled = False: txt2w.Enabled = False: txt2e.Enabled = False: txt2h.Enabled = False: txt2r.Enabled = False: txt3a.Enabled = False: txt3n.Enabled = False: txt3d.Enabled = False: txte3.Enabled = False: txtn3.Enabled = False: txtb3.Enabled = False: txt3u.Enabled = False: txt3r.Enabled = False: txt3g.Enabled = False: txt4e.Enabled = False: txt4r.Enabled = False: txt4l.Enabled = False: txt4i.Enabled = False: txt4n.Enabled = False: txt5k.Enabled = False: txt5o.Enabled = False: txt5b.Enabled = False: txt5l.Enabled = False: txt5e.Enabled = False: txt5n.Enabled = False: txt5z.Enabled = False: txt6d.Enabled = False: txt6e.Enabled = False: txt6m.Enabled = False: txt6o.Enabled = False: txt6k.Enabled = False: txt6r.Enabled = False: txt6a.Enabled = False: txt6t.Enabled = False:
txt7p.Enabled = False: txt7o.Enabled = False: txt7l.Enabled = False: txt7e.Enabled = False:  _
txt7n.Enabled = False: txt8o.Enabled = False: txt8l.Enabled = False: txt8z.Enabled = False: txt8e.Enabled = False: txt8i.Enabled = False: txt9k.Enabled = False: txt9ö.Enabled = False: txt9l.Enabled = False: txt9n.Enabled = False: txt10s.Enabled = False: txt10a.Enabled = False: txt10c.Enabled = False: txt10h.Enabled = False: txts10.Enabled = False: txt10e.Enabled = False: txt10n.Enabled = False: txt11d.Enabled = False: txte11.Enabled = False: txt11n.Enabled = False: txt11a.Enabled = False: txt11u.Enabled = False: txt11e.Enabled = False: txt11r.Enabled = False: txt12m.Enabled = False: txt12e.Enabled = False: txt12k.Enabled = False: txte12.Enabled = False: txt12l.Enabled = False: txt13e.Enabled = False: txt13l.Enabled = False: txt13b.Enabled = False: txt14i.Enabled = False: txt14d.Enabled = False: txt14e.Enabled = False: txt14r.Enabled = False: txt14l.Enabled = False: txt14a.Enabled = False: txt14n.Enabled = False:
ed = False: txt15c.Enabled = False: txt15h.Enabled = False: txt15w.Enabled = False: txt15a. _
Enabled = False: txt15r.Enabled = False: txt16c.Enabled = False: txt16h.Enabled = False: txt16t.Enabled = False: txt16z.Enabled = False: txt16e.Enabled = False: txth16.Enabled = False
End If
End Sub

Aber irgendwas stimmt hier nicht,keine Ahnung was.
Wisst ihr außerdem wie ich das in sehr viel kürzer hinbekomme ohne jedes einzelne Feld anzusprechen ?

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: HILFE D:
17.12.2014 09:29:48
Hajo_Zi
Ich baue keine Datei nach, die Zeit hat schon jemand investiert.
Ein Nachbau sieht bestimmt anders aus als das Original.
Ein Link zur Datei wäre nicht schlecht.
Benutze hier im Forum die Funktion zum hochladen. Falls Du die nicht benutzen möchtest beachte, von unsicheren Servern wie z.B. www.file-upload.net lade ich keine Datei runter. (lt. Einschätzung meines Virenprogramms)
Der Dateiname sollte was mit dem Problem zu tun haben.
Ich habe mir z.B. einen Ordner angelegt in dem ich alle Dateien aus dem Internet speichere. Bei Dateinamen wie Test..., Mappe…, Beispiel… wird eine vorhandene überschrieben.
Ein Bild in Excel geöffnet sieht anders aus als das Bild.
Ich habe kein Tool um ein Bild in Excel zu importieren.
Mache eine Schleife über die TextBoxen. In dieser Art.
Private Sub CMD_Leeren_Click()
Dim ObCb As Object
For Each ObCb In Me.Controls
If TypeName(ObCb) = "TextBox" Then
ObCb.Value = ""
ElseIf TypeName(ObCb) = "CheckBox" Then
ObCb.Value = False
ElseIf TypeName(ObCb) = "OptionButton" Then
ObCb.Value = False
End If
Next ObCb
LBL_Fehler.Caption = ""
End Sub

Anzeige
AW: HILFE D:
17.12.2014 10:12:49
Daniel
Hi
dein code ist sehr unübersichtlich.
Schreibe jeden befehl in eine eigene Zeile und nutze die Einrückungen, um hin zu strukurieren.
Dann sieht man auch schneller, ob man was optimieren kann:
so sollte dein Code aussehen:
Private Sub txt3b_Change()
If txt3b.Value = "B" Then
txt3b.BackColor = &HFF00&
Else
txt3b.BackColor = &HFF&
txt1d.Enabled = False
txtd1.Enabled = False
txt1r.Enabled = False
txt2b.Enabled = False
txt2u.Enabled = False
txt2n.Enabled = False
txt2d.Enabled = False
txt2e.Enabled = False
txth16.Enabled = False
End If
End Sub
verkürzen könnte man hier mit einer Schleife über alle Steuerelemente, die mit "txt" beginnen.
Steuereelmente, die nicht disabeld werden sollen, müssen dann einen namen haben der nicht mit "txt" beginnt oder du musst sie anschließend wieder aktivieren.
ich gehe mal davon aus, dass du eine Userform hast:
dim crt as Control
for each crt in me.Controls
if crt.Name like "txt*" then crt.Enabled = (txt3b.Value = "B")
next
txt3b.Enabled = True
if txt3b.Value = "B" then
txt3b.backcolor = &HFF00&
else
txt3b.backcolor = &HFF&
End If
Gruß Daniel
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige