ArrayList arrylist.IndexOf ArrayListのインデックスを返す  VB.NET入門

ArrayList arrylist.IndexOf ArrayListのインデックスを返す

インデックスの要素を返します。

構文
変数名.IndexOf(“データ”)

ソース
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim arrylist As New ArrayList

arrylist.Add(“ライオン”)
arrylist.Add(“ハイエナ”)
arrylist.Add(“シマウマ”)

Dim result As Integer = arrylist.IndexOf(“ライオン”)

MsgBox(result)

End Sub
End Class

実行結果は0です。

先頭の番号は0なので。
存在しない時は-1を返します。

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

Translate »