I have some problems with an array in VBScript: I have a central array, in this I save some custom objects. Later on, I want access these elements to print out the objects. But this don't work. Here is my code;
sub start
redim selektionsArray(0)
for i = 0 to 10
Dim TheDude : Set TheDude = (New Selektion2)("a" & i, "b" & i)
ReDim Preserve selektionsArray(ubound(selektionsArray) + 1)
set selektionsArray(ubound(selektionsArray)) = TheDude
'Works
msgbox selektionsArray(ubound(selektionsArray)).Typ & " = " & selektionsArray(ubound(selektionsArray)).Wert
next
dim i
for i = 0 to ubound(selektionsArray)
set element3 = selektionsArray(i)
'don't work
msgbox selektionsArray(i).Typ & " = " & selektionsArray(i).Wert
next
dim sel
for each sel in selektionsArray
'don't work to
msgbox sel.Wert
next
'strange thing is ubound(selektionsArray) --> 11
end sub
Class Selektion2
Private m_typ
Private m_wert
Public Default Function Init(Typ, Wert)
m_typ = Typ
m_wert = Wert
Set Init = Me
End Function
Public Property Get Typ
Typ = m_typ
End Property
Public Property Get Wert
Wert = m_wert
End Property
public function getWert()
getWert = m_wert
end function
End Class
I don't can access the array-Elements outside the initialisation loop, what is here wrong?