1
VBScript 배열에 몇 가지 문제가 있습니다.이 배열에는 일부 사용자 지정 개체를 저장하는 중앙 배열이 있습니다. 나중에이 요소들을 액세스하여 객체를 인쇄하고 싶습니다. 그러나 이것은 작동하지 않습니다. 내 코드는 다음과 같습니다.VBScript 배열에서 사용자 지정 개체 얻기
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
초기화 루프 외부의 배열 요소에 액세스 할 수 없습니다. 무엇이 잘못 되었습니까?
으로 변경하십시오. 지원해 주셔서 감사합니다. Ekkehard – Higune