1

私はこの単純なVB.NET関数を持っています:

Dim endval = Convert.ToInt16(googleXMLdocument...<s:currentItemCount>.Value) - 1
For counter = 0 To endval
  Dim seller = googleXMLdocument...<s:name>(counter).Value
  Dim containsValue = ToBeIgnored.AsEnumerable().Any(Function(r) r.Field(Of String)("Ignore") = seller) 
  If containsValue Then
    Continue For
  End If
  row = GoogleResults.NewRow()
  GoogleResults.Rows.Add(row)
  GoogleResults.Rows(counter)("Seller") = seller 'sometimes this line throws an exception there is no row at position x
Next

最後の行で、例外が発生することがありますthere is no row at position x。何が原因でしょうか?

4

2 に答える 2

2

カウンター変数は、GoogleResultsテーブルの行数と同じではないようです。

私はあなたがこのようなものを探していると思います:

GoogleResults.Rows(GoogleResults.Rows.Count - 1)("Seller") = seller

以上直接:

row("Seller") = seller
于 2012-10-21T13:11:57.387 に答える
1

ループの最後の2行は、次のForように書き直す必要があります。

row("Seller") = seller;
GoogleResults.Rows.Add(row)

追加後に行を変更すると、不要なイベントが発生する可能性があります。

于 2012-10-21T13:18:30.063 に答える