Seite 1 von 1

UBound / LBound

Verfasst: So 4. Nov 2012, 15:33
von wbiebel
Ich habe folgenden Code:

sub main()
msgbox Item_Anz("abc de")
end sub

public function Item_Anz(sStr as String, optional sDelim as String, optional bMode as Boolean)
Dim a() as string

if IsMissing(sDelim) then sDelim = " "
if IsMissing(bMode) then bMode = True
if len(sStr) = 0 then exit function
a = split(sStr, sDelim)
Item_Anz = UBound(a()) - LBound(a())

end function

Der Debuger sagt mir auf der letzten Zeile:
UBound(a()) ... <Out of Scope>
LBound(a()) ... <Out of Scope>
UBound(a) ... <Out of Scope>
LBound(a) ... <Out of Scope>

wobei

a(0) ... "abc"
a(1) ... "de"

Wieso sind alle "Bounds" <Out of Scope>?

Re: UBound / LBound

Verfasst: So 4. Nov 2012, 16:14
von karolus
Hallo
Wieso sind alle "Bounds" <Out of Scope>?
Das kann ich dir nicht sagen - hier funktioniert dein Code ohne Fehlermeldung.

Die Anzahl der Elemente ist aber Ubound(a)+1

Karolus