以下代码中的上一个按钮有什么问题? [英] What is wrong in the following code for previous button?

查看:113
本文介绍了以下代码中的上一个按钮有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码中的上一个按钮有什么问题?
请回答我.
如果n = dt.Rows.Count那么
n = 0
其他
tbid.Text = dt.Rows(n).Item("ID").ToString
tblocation.Text = dt.Rows(n).Item("Location").ToString
cboprovince.Text = dt.Rows(n).Item(省").ToString
tbtype.Text = dt.Rows(n).Item("Type").ToString
tbwidth.Text = dt.Rows(n).Item("Width").ToString
tbheight.Text = dt.Rows(n).Item("Height").ToString
tbremarks.Text = dt.Rows(n).Item(备注").ToString
''PictureBox1.Image = dt.Rows(n).Item(照片").ToString
昏暗的billboardimage()为字节= CType(dt.Rows(n).Item(照片"),Byte())
昏暗的毫秒作为新的MemoryStream(billboardimage)
PictureBox1.Image = Image.FromStream(ms)
n-= 1
如果If

What is wrong in the following code for previous button?
please answer me.
If n = dt.Rows.Count Then
n = 0
Else
tbid.Text = dt.Rows(n).Item("ID").ToString
tblocation.Text = dt.Rows(n).Item("Location").ToString
cboprovince.Text = dt.Rows(n).Item("Province").ToString
tbtype.Text = dt.Rows(n).Item("Type").ToString
tbwidth.Text = dt.Rows(n).Item("Width").ToString
tbheight.Text = dt.Rows(n).Item("Height").ToString
tbremarks.Text = dt.Rows(n).Item("Remarks").ToString
''PictureBox1.Image = dt.Rows(n).Item("Photo").ToString
Dim billboardimage() As Byte = CType(dt.Rows(n).Item("Photo"), Byte())
Dim ms As New MemoryStream(billboardimage)
PictureBox1.Image = Image.FromStream(ms)
n -= 1
End If

推荐答案

Um.
结束
你没看到吗?
假设您有三个项目,并且正在查看第二个项目:
n == 1
计数== 3
您执行代码,n变为n-1:现在n == 0
您执行代码,然后对n进行3校验,所以不是,因此继续操作,n变为n-1:现在n == -1
您执行了男女同校,然后再次检查n3.它仍然不是,所以您继续....并且n继续得到越来越多的负面信息(嗯,实际上它不会,因为您的应用程序将崩溃瞬间是负面的,但你明白了...)

请学习使用调试器,并按照以下代码进行操作:如果有,您将在几秒钟内发现它!
Um.

You don''t see it?
Suppose you have three items, and you are viewing the second:
n == 1
Count == 3
You execute your code, and n becomes n - 1 : now n == 0
You execute your code, and n is checked against 3, it isn''t, so you continue and n becomes n - 1 : now n == -1
You execute your coed, and check n agains 3. It still isn''t, so you continue....and n continues to get more and more negative (well, actually it won''t, because your app will crash the moment it is negative, but you get the idea...)

Please, learn to use the debugger, and follow your code through: if you had, you would have spotted this yourself in a couple of seconds!


这篇关于以下代码中的上一个按钮有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆