Redim Datenfeld
19.10.2004 19:43:10
Jens_Pu
kann mir bitte mal jemand auf die Sprünge helfen, was da falsch ist. Sobald die For Each Schleife den 2. Durchgang macht, steigt er bei Redim aus (Index außerhalb...). Ich begreife es nicht. Danke schon mal.
Option Explicit
Option Base 1
Private Sub Controlwerte_in_Datenfeld()
Dim ctlFrame As Control
Dim cnt As Control
Dim intI As Integer
Dim arrFrames As Variant
Dim arrCbo() As Variant
Dim arrTxt() As Variant
Dim intArrCboCount As Integer
Dim intArrTxtCount As Integer
arrFrames = Array("Frame1", "Frame2", "Frame3", "Frame4") 'ZE, BA, FG, Onl
For intI = LBound(arrFrames) To UBound(arrFrames) 'Schleife über die Frames
Set ctlFrame = Controls(arrFrames(intI))
intArrCboCount = 1
intArrTxtCount = 1
For Each cnt In ctlFrame.Controls 'Schleife über die Controls eines Frames
If TypeName(cnt) = "ComboBox" Then
'Was gemacht werden muß bei einer ComboBox
ReDim Preserve arrCbo(intArrCboCount, 4)
arrCbo(intArrCboCount, 1) = cnt.Name
arrCbo(intArrCboCount, 2) = cnt.Value
arrCbo(intArrCboCount, 3) = cnt.text
arrCbo(intArrCboCount, 4) = cnt.Tag
intArrCboCount = intArrCboCount + 1
Else
'Was bei allen andern Controls gemacht wird
If TypeName(cnt) = "TextBox" Then
'Was gemacht werden muß bei einer ComboBox
ReDim Preserve arrTxt(intArrTxtCount, 4)
arrTxt(intArrTxtCount, 1) = cnt.Name
arrTxt(intArrTxtCount, 2) = cnt.Value
arrTxt(intArrTxtCount, 3) = cnt.text
arrTxt(intArrTxtCount, 4) = cnt.Tag
intArrTxtCount = intArrTxtCount + 1
End If
End If
Next cnt
Next intI
End Sub