InvalidArgument =值'1'对'index'无效。 [英] InvalidArgument=Value of '1' is not valid for 'index'.
本文介绍了InvalidArgument =值'1'对'index'无效。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<pre lang="vb"><pre lang="vb">Dim ans As Double
For z As Integer = 0 To ListBox1.Items.Count
ans = Math.Sqrt((ListBox1.Items(z) - ListBox3.Items(z)) ^ 2 + Convert.ToInt32(ListBox2.Items(z) - ListBox4.Items(z)) ^ 2)
ListBox5.Items.Add(ans)</pre></pre>
i尝试一下,但是这样的错误。
InvalidArgument ='1'的值对'index'无效。
任何人都可以帮帮我?
i try it, but error like this.
InvalidArgument=Value of '1' is not valid for 'index'.
anyone could help me?
推荐答案
使用这个;)
use This ;)
For z As Integer = 0 To ListBox1.Items.Count -1
项目为零基于..
计数返回1 ..意味着只有项目索引0
但你再循环通过它wi th index 1 ..这是你得到错误的地方
因为没有项目(1)!
greets
Items is zero based ..
count returns 1 .. means there is only the item index 0
but you loop again through it with index 1 ..this is where you get your error
because there is no item(1)!
greets
这篇关于InvalidArgument =值'1'对'index'无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文