Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
252to256
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
252to256
252to256
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

commandbutton mit eingabeüberprüfung

commandbutton mit eingabeüberprüfung
08.05.2003 09:40:38
nobby
hallo,

ich habe ein kleines userform mit 4 textboxen. per 1. commandbutton werden die eingaben in eine tabelle eingetragen.
dabei soll auch mit einer if bedingung geprüft werden, ob die textboxen einträge enthalten oder ob sie leer sind. wenn eine oder mehrere textboxen leer sind, soll ein alert auf die fehlenden felder hinweisen:

if textbox1.value ="" then
alert "Bitte die Eingaben überprüfen" ..oder so ähnlich.

bin leider excel-dilettant und würde mich über hilfe freuen.

nobby



8
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Re: commandbutton mit eingabeüberprüfung
08.05.2003 09:50:56
Andi_H

hi,
hier mal ein ansatz

dim tb as object

for each tb in userform1.controls
if typename(tb) = "TextBox" then
if isempty(tb) then
MSGBOX("Bitte Eingabe überprüfen")
exit sub
end if
end if
next

diese schleife überprüft alle Textboxen auf Inhalt, wenn eine der tbs leer sein sollte bringt er den fehlerhinweis und beendet die Sub
Einfach in deinen Code einfügen

hoffe des hilft

gruß

Andi

Re: commandbutton mit eingabeüberprüfung
08.05.2003 10:09:16
nobby

hi andy,

danke für deinen tipp. irgendeine kleinigkeit stimmt noch nicht, weil bei einem oder mehreren leeren feldern keine fehlermeldung erfolgt. hier mal der code für den commandbutton, der die übergabe der einträge in die tabelle regelt. vielleicht siehst du da irgendwelche fehler:

Private Sub CommandButton1_Click()
z = 4
Do While Cells(z, 1) <> ""
z = z + 1
Loop
Cells(z, 1) = Me.TextBox1
Cells(z, 2) = Me.TextBox2
Cells(z, 3) = Me.TextBox3
Cells(z, 4) = Me.TextBox4

Dim tb As Object
For Each tb In UserForm2.Controls
If TypeName(tb) = "TextBox1" Then

If IsEmpty(tb) Then
MsgBox ("Bitte Eingabe überprüfen")
Exit Sub
End If

End If
Next

.
.
.
.
.
.
.

nobby



Anzeige
Re: commandbutton mit eingabeüberprüfung
08.05.2003 10:23:06
Andi_H

hi nobby,

lösch in u.g. Zeite die 1 hinter Textbox raus, dann prüft er alle, nicht nur tb1
If TypeName(tb) = "TextBox1" Then

ansonsten is mir nix aufgefallen

viel spaß beim weiterexceln,

andi


Re: commandbutton mit eingabeüberprüfung
08.05.2003 10:46:21
nobby

hi andy,

ich habe die 1 entfernt. das teil läuft leider immer noch nicht.
kann es an etwas anderem liegen? vielleicht hast du ja noch eine idee.

nobby

Re: commandbutton mit eingabeüberprüfung
08.05.2003 10:54:18
Andi_H

eigentlich nicht, ich verwende noch o97 und da läuft die prüfung fehlerfrei in meinen userforms. Eine Möglichkeit wäre natürlich auch das du per If then jede TB ansprichst bei der Prüfung, nicht über schleife.
if isempty(textbox1.text) then goto err:
if isempty(textbox2.text) then goto err:
.
.
.
exit sub
err:
msgbox("Bitte Eingabe überprüfen")
end sub



Anzeige
Re: commandbutton mit eingabeüberprüfung
08.05.2003 12:16:24
nobby

hi andy,

klappt immer noch nicht. irgendwas mache ich völlig falsch.
Ich geb dir mal den kompletten code für den commandbutton.
vielleicht fällt dir noch was ein.

Nobby


Private Sub CommandButton1_Click()
z = 4
Do While Cells(z, 1) <> ""
z = z + 1
Loop
Cells(z, 1) = Me.TextBox1
If IsEmpty(TextBox1) Then GoTo err:
End If

Cells(z, 2) = Me.TextBox2
If IsEmpty(TextBox2) Then GoTo err:
End If

Cells(z, 3) = Me.TextBox3
If IsEmpty(TextBox1) Then GoTo err:
End If

Cells(z, 4) = Me.TextBox4
If IsEmpty(TextBox1) Then GoTo err:
End If

Cells(z, 5) = Me.CheckBox1
If CheckBox1.Value = True Then
Cells(z, 5) = "x"
Else
Cells(z, 5) = ""
End If

Cells(z, 6) = Me.CheckBox2
If CheckBox2.Value = True Then
Cells(z, 6) = "x"
Else
Cells(z, 6) = ""
End If

Cells(z, 7) = Me.CheckBox3
If CheckBox3.Value = True Then
Cells(z, 7) = "x"
Else
Cells(z, 7) = ""
End If

Cells(z, 8) = Me.CheckBox4
If CheckBox4.Value = True Then
Cells(z, 8) = "x"
Else
Cells(z, 8) = ""
End If

Cells(z, 9) = Me.CheckBox5
If CheckBox5.Value = True Then
Cells(z, 9) = "x"
Else
Cells(z, 9) = ""
End If


Cells(z, 10) = Me.CheckBox6
If CheckBox6.Value = True Then
Cells(z, 10) = "x"
Else
Cells(z, 10) = ""
End If

Cells(z, 11) = Me.CheckBox7
If CheckBox7.Value = True Then
Cells(z, 11) = "x"
Else
Cells(z, 11) = ""
End If

Cells(z, 12) = Me.CheckBox8
If CheckBox8.Value = True Then
Cells(z, 12) = "x"
Else
Cells(z, 12) = ""
End If

Cells(z, 13) = Me.CheckBox9
If CheckBox9.Value = True Then
Cells(z, 13) = "x"
Else
Cells(z, 13) = ""
End If

Cells(z, 14) = Me.CheckBox10
If CheckBox10.Value = True Then
Cells(z, 14) = "x"
Else
Cells(z, 14) = ""
End If


Cells(z, 15) = Me.CheckBox11
If CheckBox11.Value = True Then
Cells(z, 15) = "x"
Else
Cells(z, 15) = ""
End If

Cells(z, 16) = Me.CheckBox12
If CheckBox12.Value = True Then
Cells(z, 16) = "x"
Else
Cells(z, 16) = ""
End If

Cells(z, 17) = Me.CheckBox13
If CheckBox13.Value = True Then
Cells(z, 17) = "x"
Else
Cells(z, 17) = ""
End If

Cells(z, 18) = Me.CheckBox14
If CheckBox14.Value = True Then
Cells(z, 18) = "x"
Else
Cells(z, 18) = ""
End If

Cells(z, 19) = Me.CheckBox15
If CheckBox15.Value = True Then
Cells(z, 19) = "x"
Else
Cells(z, 19) = ""
End If

Cells(z, 20) = Me.CheckBox16
If CheckBox16.Value = True Then
Cells(z, 20) = "x"
Else
Cells(z, 20) = ""
End If

Cells(z, 21) = Me.CheckBox17
If CheckBox17.Value = True Then
Cells(z, 21) = "x"
Else
Cells(z, 21) = ""
End If

Cells(z, 22) = Me.CheckBox18
If CheckBox18.Value = True Then
Cells(z, 22) = "x"
Else
Cells(z, 22) = ""
End If

Cells(z, 23) = Me.CheckBox19
If CheckBox19.Value = True Then
Cells(z, 23) = "x"
Else
Cells(z, 23) = ""
End If

Cells(z, 24) = Me.CheckBox20
If CheckBox20.Value = True Then
Cells(z, 24) = "x"
Else
Cells(z, 24) = ""
End If

Cells(z, 25) = Me.CheckBox21
If CheckBox21.Value = True Then
Cells(z, 25) = "x"
Else
Cells(z, 25) = ""
End If

Cells(z, 26) = Me.CheckBox22
If CheckBox22.Value = True Then
Cells(z, 26) = "x"
Else
Cells(z, 26) = ""
End If

Cells(z, 27) = Me.CheckBox23
If CheckBox23.Value = True Then
Cells(z, 27) = "x"
Else
Cells(z, 27) = ""
End If

Cells(z, 28) = Me.CheckBox24
If CheckBox24.Value = True Then
Cells(z, 28) = "x"
Else
Cells(z, 28) = ""
End If

Cells(z, 29) = Me.CheckBox25
If CheckBox25.Value = True Then
Cells(z, 29) = "x"
Else
Cells(z, 29) = ""
End If

Cells(z, 30) = Me.CheckBox26
If CheckBox26.Value = True Then
Cells(z, 30) = "x"
Else
Cells(z, 30) = ""
End If

Exit Sub
err:
MsgBox ("Bitte alle Textfelder vollständig ausfüllen!")
End Sub

End Sub

Anzeige
das muß es sein!
08.05.2003 12:39:04
Andi_H

Ich glaube den Fehler gefunden zu haben
hab das jetzt selbst versucht und habe festgestellt das Excel bei TBs nicht aufg isempty reagiert.
Hab deinen Code bei mir versucht und des klappt
grüße aus regensburg


Andi

Private Sub CommandButton1_Click()
z = 4
Do While Cells(z, 1) <> ""
z = z + 1
Loop


For Each tb In UserForm1.Controls
If TypeName(tb) = "TextBox" Then
If tb.Text = "" Then GoTo err:
End If
Next

Cells(z, 1) = Me.TextBox1

Cells(z, 2) = Me.TextBox2

Cells(z, 3) = Me.TextBox3

Cells(z, 4) = Me.TextBox4

Cells(z, 5) = Me.CheckBox1
If CheckBox1.Value = True Then
Cells(z, 5) = "x"
Else
Cells(z, 5) = ""
End If

Cells(z, 6) = Me.CheckBox2
If CheckBox2.Value = True Then
Cells(z, 6) = "x"
Else
Cells(z, 6) = ""
End If

Cells(z, 7) = Me.CheckBox3
If CheckBox3.Value = True Then
Cells(z, 7) = "x"
Else
Cells(z, 7) = ""
End If

Cells(z, 8) = Me.CheckBox4
If CheckBox4.Value = True Then
Cells(z, 8) = "x"
Else
Cells(z, 8) = ""
End If

Cells(z, 9) = Me.CheckBox5
If CheckBox5.Value = True Then
Cells(z, 9) = "x"
Else
Cells(z, 9) = ""
End If


Cells(z, 10) = Me.CheckBox6
If CheckBox6.Value = True Then
Cells(z, 10) = "x"
Else
Cells(z, 10) = ""
End If

Cells(z, 11) = Me.CheckBox7
If CheckBox7.Value = True Then
Cells(z, 11) = "x"
Else
Cells(z, 11) = ""
End If

Cells(z, 12) = Me.CheckBox8
If CheckBox8.Value = True Then
Cells(z, 12) = "x"
Else
Cells(z, 12) = ""
End If

Cells(z, 13) = Me.CheckBox9
If CheckBox9.Value = True Then
Cells(z, 13) = "x"
Else
Cells(z, 13) = ""
End If

Cells(z, 14) = Me.CheckBox10
If CheckBox10.Value = True Then
Cells(z, 14) = "x"
Else
Cells(z, 14) = ""
End If


Cells(z, 15) = Me.CheckBox11
If CheckBox11.Value = True Then
Cells(z, 15) = "x"
Else
Cells(z, 15) = ""
End If

Cells(z, 16) = Me.CheckBox12
If CheckBox12.Value = True Then
Cells(z, 16) = "x"
Else
Cells(z, 16) = ""
End If

Cells(z, 17) = Me.CheckBox13
If CheckBox13.Value = True Then
Cells(z, 17) = "x"
Else
Cells(z, 17) = ""
End If

Cells(z, 18) = Me.CheckBox14
If CheckBox14.Value = True Then
Cells(z, 18) = "x"
Else
Cells(z, 18) = ""
End If

Cells(z, 19) = Me.CheckBox15
If CheckBox15.Value = True Then
Cells(z, 19) = "x"
Else
Cells(z, 19) = ""
End If

Cells(z, 20) = Me.CheckBox16
If CheckBox16.Value = True Then
Cells(z, 20) = "x"
Else
Cells(z, 20) = ""
End If

Cells(z, 21) = Me.CheckBox17
If CheckBox17.Value = True Then
Cells(z, 21) = "x"
Else
Cells(z, 21) = ""
End If

Cells(z, 22) = Me.CheckBox18
If CheckBox18.Value = True Then
Cells(z, 22) = "x"
Else
Cells(z, 22) = ""
End If

Cells(z, 23) = Me.CheckBox19
If CheckBox19.Value = True Then
Cells(z, 23) = "x"
Else
Cells(z, 23) = ""
End If

Cells(z, 24) = Me.CheckBox20
If CheckBox20.Value = True Then
Cells(z, 24) = "x"
Else
Cells(z, 24) = ""
End If

Cells(z, 25) = Me.CheckBox21
If CheckBox21.Value = True Then
Cells(z, 25) = "x"
Else
Cells(z, 25) = ""
End If

Cells(z, 26) = Me.CheckBox22
If CheckBox22.Value = True Then
Cells(z, 26) = "x"
Else
Cells(z, 26) = ""
End If

Cells(z, 27) = Me.CheckBox23
If CheckBox23.Value = True Then
Cells(z, 27) = "x"
Else
Cells(z, 27) = ""
End If

Cells(z, 28) = Me.CheckBox24
If CheckBox24.Value = True Then
Cells(z, 28) = "x"
Else
Cells(z, 28) = ""
End If

Cells(z, 29) = Me.CheckBox25
If CheckBox25.Value = True Then
Cells(z, 29) = "x"
Else
Cells(z, 29) = ""
End If

Cells(z, 30) = Me.CheckBox26
If CheckBox26.Value = True Then
Cells(z, 30) = "x"
Else
Cells(z, 30) = ""
End If


Exit Sub
err:
MsgBox ("Bitte alle Textfelder vollständig ausfüllen!")
End Sub



Anzeige
Re: das muß es sein!
08.05.2003 13:11:52
nobby

hi andy,

du hast recht. jetzt klappt alles einwandfrei.
großen dank für deine hilfe und noch nen schönen tag.

nobby

300 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige