VB.NET中的索引范围异常的奇怪问题
我在VB.NET(2019)项目中有一个DGV,并且在特定行索引中复制了单元格,但是AM遇到了一个奇怪的问题:
TXTItemDetail.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(1).Value
TXTOuterpackQTY.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(2).Value
TXTOuterpackName.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(3).Value
TXTItemCodeSelected.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(4).Value
TXTCGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(7).Value
TXTSGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(8).Value
TXTIGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(9).Value
TSSLHSNCode.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(10).Value
TXTItemCode.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(11).Value
'Error is thrown at the line below!!
TXTRate.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(5).Value.ToString
请注意,在生成错误的线上,单元格索引在5时为5该代码已经在较早的代码行中贯穿了更高的索引,直至单元11。然而,在这种情况下会生成范围错误。 我能确定的是,我需要按顺序将代码线置于单元号的出现方式。例如,如果我在4后放置5个单元格5,则不会抛出此错误。
我在许多地方都使用过这种代码,但是从未遇到过这种类型的问题。 VB可能是某种线程问题吗?
谢谢。
I have a DGV in a VB.NET(2019) project and I copy the cells at specific row index, but am experiencing a strange issue:
TXTItemDetail.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(1).Value
TXTOuterpackQTY.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(2).Value
TXTOuterpackName.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(3).Value
TXTItemCodeSelected.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(4).Value
TXTCGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(7).Value
TXTSGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(8).Value
TXTIGST.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(9).Value
TSSLHSNCode.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(10).Value
TXTItemCode.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(11).Value
'Error is thrown at the line below!!
TXTRate.Text = DGVItemSearch.Rows(ItemEnteredRow).Cells(5).Value.ToString
Note that on the line on which the error is being generated, the cell index is at 5 while the code has already run through on even higher indexes in the earlier lines of code, going up to cell 11. Yet, an out of range error is generated at this instance.
What I could determine was that I need to place the lines of code in sequence of how the cell numbers appear. For example, if I place cell 5 after 4, this error will not be thrown.
I have used this type of code in many places, but never came across this type of an issue. Could it be some kind of threading issue in VB?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论