特定の列の行の値を取得するには、行オブジェクトの直後に括弧を使用し、ColumnName
またはColumnIndex
プロパティを指定して値を取得できます。
また、複数の潜在的な値がある場合case
、多くのステートメントの代わりにステートメントを使用できますElseIf
。
MVCE セットアップ
'declare local variables
Dim dr As DataRow
'create table
Dim studentLogs As New DataTable("StudentLogs")
'add columns
With studentLogs
.Columns.Add("Status", GetType(Integer))
.Columns.Add("OtherCol1", GetType(String))
End With
'add values
With studentLogs
dr = studentLogs.NewRow()
dr("Status") = 1
dr("OtherCol1") = "Joey"
studentLogs.Rows.Add(dr)
End With
列の値/行のステータスを確認する
For Each row As DataRow In studentLogs.Rows
Select Case row("Status")
Case 1
Call SENDSMS()
Case 2
MsgBox("2")
Exit For
Case 3
MsgBox("3")
End Select
Next