[VB6 ] 請問程式計算結果的問題

作者: Fmajor (萬物靜觀皆自得)   2015-11-25 22:23:49
Dim i, Result ,MyArray, Name
Name ="X"
MyArray = Array("A", "B", "C", "D")
Result = Filter(MyArray, Name , True)
MsgBox UBound(Result)
請問為什麼X不包含在陣列值,結果會是-1
(值不在陣列中,不是UBound(0)=0嗎?)?
若,
Name = "D"
Result = Filter(MyArray, Name , True)
則MsgBox UBound(Result)
為什麼有在陣列的值,結果會是0呢
(值在陣列中,不是UBound(1)=1嗎?)?
其實主要是想寫若
Name的值在陣列中,則會回傳訊息顯示"正常運作"
若不在陣列中,則會回傳訊息"錯誤"
再麻煩指導,感謝~
作者: johnpage (johnpage)   2015-11-26 06:34:00
Filter的定義
作者: peakhour   2015-12-02 01:26:00
ubound 返回的不是個數,而是index
作者: Fmajor (萬物靜觀皆自得)   2015-12-06 00:32:00
感謝提醒,已經知道哪邊錯誤了,謝謝兩位大大

Links booklink

Contact Us: admin [ a t ] ucptt.com