Anzeige
Archiv - Navigation
1228to1232
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

finde den fehler nicht

finde den fehler nicht
amintire
Hallo alle zusammen,
hab eine UserForm mit MultiPage1 (fünf Register)
Bei dem ersten Register funktioniert der Code,
aber beim zweiten mag der mir irgendwie die TextBox6 nicht füllen,
weiß echt nicht woran das liegt, beide Codes sind ja identisch.
Vielleicht hat jemand Rat. Danke.
Lieben Gruß
Amina
'Register1

Private Sub SpinButton1_Change()
Image1.Picture = LoadPicture(arrFotos(SpinButton1))
Label1 = SpinButton1 + 1
TextBox1 = arrFotos(SpinButton1)
Repaint
Dim vartmp As Variant
With Tabelle13 'Mitarbeiter
vartmp = Application.Match(TextBox1.Text, .Range("A:A"), 0)
If Not IsError(vartmp) Then
Me.Tag = vartmp
TextBox2.Text = .Cells(vartmp, 2).Value
Else
Me.Tag = ""
TextBox2.Text = ""
End If
End With
End Sub

'Register 2

Private Sub SpinButton2_Change()
Image2.Picture = LoadPicture(arrfotos1(SpinButton2))
Label4 = SpinButton2 + 1
TextBox5 = arrfotos1(SpinButton2)
Repaint
Dim vartmp1 As Variant
With Tabelle14 'Mitarbeiter
vartmp1 = Application.Match(TextBox6.Text, .Range("A:A"), 0)
If Not IsError(vartmp1) Then
Me.Tag = vartmp1
TextBox6.Text = .Cells(vartmp1, 2).Value
Else
Me.Tag = ""
TextBox6.Text = ""
End If
End With
End Sub

14
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: finde den fehler nicht
27.09.2011 11:28:13
Dirk
Hallo!
Schau mal ob Dein Array richtig benannt ist : im Register2 heisst es arrfotos1 anstelle von arrFotos
Gruss
Dirk aus Dubai
AW: finde den fehler nicht
27.09.2011 11:34:15
amintire
Hallo Dirk,
ist richtig benannt, es muss auch arrfotos1 heißen bei Register 2, da sich der Pfad für die Bilddateien ändert.
Der muss aber im Register 2 die Tabelle14 hernehmen,
im Register1 mit der Tabelle13 funktioniert es ja komischerweise
Gruß Amina
AW: der ganze code
27.09.2011 11:37:30
amintire
Also so ist der ganze Code den ich in der UserForm habe:
Option Explicit
Dim arrFotos
Dim arrfotos1
Dim arrfotos2
Dim arrfotos3
Dim arrfotos4

Private Sub SpinButton1_Change()
Image1.Picture = LoadPicture(arrFotos(SpinButton1))
Label1 = SpinButton1 + 1
TextBox1 = arrFotos(SpinButton1)
Repaint
Dim vartmp As Variant
With Tabelle13 'Mitarbeiter
vartmp = Application.Match(TextBox1.Text, .Range("A:A"), 0)
If Not IsError(vartmp) Then
Me.Tag = vartmp
TextBox2.Text = .Cells(vartmp, 2).Value
Else
Me.Tag = ""
TextBox2.Text = ""
End If
End With
End Sub


Private Sub SpinButton2_Change()
Image2.Picture = LoadPicture(arrfotos1(SpinButton2))
Label4 = SpinButton2 + 1
TextBox5 = arrfotos1(SpinButton2)
Repaint
Dim vartmp1 As Variant
With Tabelle14 'Mitarbeiter
vartmp1 = Application.Match(TextBox6.Text, .Range("A:A"), 0)
If Not IsError(vartmp1) Then
Me.Tag = vartmp1
TextBox6.Text = .Cells(vartmp1, 2).Value
Else
Me.Tag = ""
TextBox6.Text = ""
End If
End With
End Sub


Private Sub SpinButton3_Change()
Image3.Picture = LoadPicture(arrfotos2(SpinButton3))
Label6 = SpinButton3 + 1
TextBox9 = arrfotos2(SpinButton3)
Repaint
Dim vartmp As Variant
With Tabelle15 'Mitarbeiter
vartmp = Application.Match(TextBox10.Text, .Range("A:A"), 0)
If Not IsError(vartmp) Then
Me.Tag = vartmp
TextBox10.Text = .Cells(vartmp, 2).Value
Else
Me.Tag = ""
TextBox10.Text = ""
End If
End With
End Sub


Private Sub SpinButton4_Change()
Image4.Picture = LoadPicture(arrfotos3(SpinButton4))
Label13 = SpinButton4 + 1
TextBox13 = arrfotos3(SpinButton4)
Repaint
End Sub


Private Sub SpinButton5_Change()
Image5.Picture = LoadPicture(arrfotos4(SpinButton5))
Label20 = SpinButton5 + 1
TextBox17 = arrfotos4(SpinButton5)
Repaint
End Sub


Private Sub UserForm_Activate()
'Register 1
Dim oFotos As Object, sFile As String
Dim sPath As String
sPath = Sheets("Bildpfad").Cells(2, 2) & "Kein Foto\"
Set oFotos = CreateObject("Scripting.Dictionary")
Dim Verz As String
Verz = Sheets("Bildpfad").Cells(2, 2)
sFile = Dir(Verz & "*.jpg")
Do While sFile  ""
oFotos(Verz & sFile) = 0
sFile = Dir
Loop
arrFotos = oFotos.keys
SpinButton1.Max = oFotos.Count - 1
TextBox1 = arrFotos(0)
Image1.Picture = LoadPicture(arrFotos(0))
Label1 = "1"
Label2 = oFotos.Count
'Register 2
Dim oFotos1 As Object, sFile1 As String
Dim sPath1 As String
sPath1 = Sheets("Bildpfad").Cells(3, 2) & "Kein Foto\"
Set oFotos1 = CreateObject("Scripting.Dictionary")
Dim Verz1 As String
Verz1 = Sheets("Bildpfad").Cells(3, 2)
sFile1 = Dir(Verz1 & "*.jpg")
Do While sFile1  ""
oFotos1(Verz1 & sFile1) = 0
sFile1 = Dir
Loop
arrfotos1 = oFotos1.keys
SpinButton2.Max = oFotos1.Count - 1
TextBox5 = arrfotos1(0)
Image2.Picture = LoadPicture(arrfotos1(0))
Label4 = "1"
Label5 = oFotos1.Count
'Register 3
Dim oFotos2 As Object, sFile2 As String
Dim sPath2 As String
sPath2 = Sheets("Bildpfad").Cells(4, 2) & "Kein Foto\"
Set oFotos2 = CreateObject("Scripting.Dictionary")
Dim Verz2 As String
Verz2 = Sheets("Bildpfad").Cells(4, 2)
sFile2 = Dir(Verz2 & "*.jpg")
Do While sFile2  ""
oFotos2(Verz2 & sFile2) = 0
sFile2 = Dir
Loop
arrfotos2 = oFotos2.keys
SpinButton3.Max = oFotos2.Count - 1
TextBox9 = arrfotos2(0)
Image3.Picture = LoadPicture(arrfotos2(0))
Label6 = "1"
Label7 = oFotos2.Count
'Register 4
Dim oFotos3 As Object, sFile3 As String
Dim sPath3 As String
sPath3 = Sheets("Bildpfad").Cells(5, 2) & "Kein Foto\"
Set oFotos3 = CreateObject("Scripting.Dictionary")
Dim Verz3 As String
Verz3 = Sheets("Bildpfad").Cells(5, 2)
sFile3 = Dir(Verz3 & "*.jpg")
Do While sFile3  ""
oFotos3(Verz3 & sFile3) = 0
sFile3 = Dir
Loop
arrfotos3 = oFotos3.keys
SpinButton4.Max = oFotos3.Count - 1
TextBox13 = arrfotos3(0)
Image4.Picture = LoadPicture(arrfotos3(0))
Label13 = "1"
Label14 = oFotos3.Count
'Register 5
Dim oFotos4 As Object, sFile4 As String
Dim sPath4 As String
sPath4 = Sheets("Bildpfad").Cells(6, 2) & "Kein Foto\"
Set oFotos4 = CreateObject("Scripting.Dictionary")
Dim Verz4 As String
Verz4 = Sheets("Bildpfad").Cells(6, 2)
sFile4 = Dir(Verz4 & "*.jpg")
Do While sFile4  ""
oFotos4(Verz4 & sFile4) = 0
sFile4 = Dir
Loop
arrfotos4 = oFotos4.keys
SpinButton5.Max = oFotos4.Count - 1
TextBox17 = arrfotos4(0)
Image5.Picture = LoadPicture(arrfotos4(0))
Label20 = "1"
Label21 = oFotos4.Count
End Sub

Gruß Amina
Anzeige
AW: der ganze code
27.09.2011 11:39:03
Dirk
Hallo!
Lade doch besser die Datei hoch, da kann man dann im Einzelschritt durchgehen und sehen, was in den Arrays bzw. Variablen steht.
Gruss\
Dirk aus Dubai
AW: Datei
27.09.2011 11:56:39
Dirk
Hallo!
Habe leider keine Daten in Deinen Pfaden. Daher mal anders:
Gehe mal in den VBE und setze einen Haltepunkt (F9) am anfang des Userform_Activate macros und gehe dann mit F8 schrittweise durch das Makro.
An welcher stelle kommt denn die Fehlermeldung?
Gruss
Dirk aus Dubai
Anzeige
AW: Datei
27.09.2011 12:08:34
amintire
Hallo Dirk,
das Problem ist, das keine Fehlermeldung kommt,
die TextBox im Register 2 wird nur nicht beschrieben.
Gruß Amina
AW: Datei
27.09.2011 12:17:01
Dirk
Hallo!
Dann schau mal nach was beim Kommando zum Beschreiben der Textbox an parametern vorhanden ist.
Kannst Dir die Werte in der Immediate box mit debug.print ausgeben.
Schau mal nach ob in Tabelle14 an der angegebenen Stelle Werte vorhanden sind.
Gruss
Dirk aus Dubai
AW: Datei
27.09.2011 12:28:05
amintire
Hallo,
versteh kein Wort ;)
In Tabelle 14 sind aufjedenfall Werte vorhanden.
Gruß Amina
AW: Datei
27.09.2011 12:32:04
Dirk
Hallo!
Bist Du schon mal im Schrittmodus durch Deine Makros gegangen?
Gruss
Dirk aus Dubai
Anzeige
AW: Datei
27.09.2011 12:39:47
amintire
Ja, beim ersten Code SpinButton1 zeigt er mir das TextBox1.text einen Inhalt hat,
aber beim zweiten Code SpinnButton2 zeigt er mir das TextBox6.text leer ist.
Aber in der Tabelle14 sind Daten vorhanden, genauso wie in Tabelle13...
Ich check das nicht ;)
Gruß Amina
AW: Datei
27.09.2011 12:55:56
Dirk
Hallo!
Du musst im Einzelschritt mit F8 durch Dein Makr gehen und dann nach der Schleife beim Kommando arrfotos1 = oFotos1.keys
nachsehen, ob das Array ArrFotos1 gefuellt ist, z.b. im Direktfebnster das Kommando
debug.print arrFotos1(0)
eingeben.
Kommt keine Ausgabe hasst Du auch keinen Wert zum Anzeigen.
Falls Du das mit dem Direktfenster nicht hinbekommst, kannst Du auch alles in MsgBox ausgeben,
z.b msgBox arrfotos1(0)
gruss
Dirk aus Dubai
Anzeige
AW: Datei
27.09.2011 12:59:23
fcs
Hallo Amintire,
beim 1. Spinbutton wird der Inhalt aus Textbox1 in der Spalte A gesucht und das Ergebnis in der TextBox2 eingetragen.
beim 2. Spinbutton wird der Inhalt aus Textbox6 in der Spalte A gesucht und das Ergebnis soll auch wieder in der TextBox6 eingetragen werden.
Ohne mir deine Datei anzusehen nehme ich an, dass beim 2. Button eine der beiden TextBox-Nummern falsch ist. Solange TextBox6 leer ist, findet Match beim suchen eine Leerzeile oder gibt einen Fehler zurück.
Gruß
Franz
AW: DANKE
27.09.2011 13:04:19
amintire
Bin jetzt auch dahinter gekommen, nachdem ich mir die zwei Codes angeschaut habe.
Du hast vollkommen Recht Franz, dachte schon ich verblöde langsam ;))
Danke für eure Hilfe.
Lieben Gruß
Amina
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige