如何比较visual basic中列表的项目? [英] How do I compare between the items of a list in visual basic?

查看:57
本文介绍了如何比较visual basic中列表的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我试图将SQL数据库2008中整数的siftsize数据存储到列表中,然后像list [i]和list [i + 1]之间进行比较然后选择对应的图像进行筛选并将其显示在列表视图中。

首先,我使用了字典,但它无法正常工作。

我试过列表,同样的结果,我意味着没有结果!!

请帮助..



我尝试过:



Hi guys,
I am trying to store siftsize data which is integer from SQL database 2008 to a list, then compare between them like list [i] and list[i+1] then chose the correspondant images to the siftsize and display it in a listview.
First, I used a dictionary but it dodn't work.
I tried lists, same result, i mean no result !!
Please help ..

What I have tried:

<pre>Query = "select siftSize from framesDef"
cmd.CommandText = Query
Dim res = cmd.ExecuteReader()
While res.Read()
    'sic.Add(res("frameID"), res("siftSize"))
    ar.Add(res("siftSize"))
    'res_lab.Text = ar(indx)
    'Just to test the dictionary
    indx += 1
End While
For j As Integer = 0 To indx
    If ar.ElementAtOrDefault(indx) And >= 463 Then
        Query = "select frameName from framesDef where siftSize  between 510 and 1000"
        cmd.CommandText = Query
        Dim res2 = cmd.ExecuteReader()
        While res2.Read()
            'trying to put the result of the query in a list named: fid
            fid.Add(res("frameName"))
        End While
    End If
    For Each i As String In Directory.GetFiles("C:\Users\DELL\Documents\Visual Studio 2010\Projects\4\testFolder4")
        If fid.ElementAtOrDefault(indx) = i Then
            'resulted images in the listview: lv_res
            lv_res.Items.Add(i)
        End If
    Next
Next

推荐答案

引用:

首先,我使用了一本字典,但它没有用。

我试过列表,结果相同,我的意思是没有结果!

First, I used a dictionary but it dodn't work.
I tried lists, same result, i mean no result !!



这没用。



当你不明白你的代码在做什么或为什么它做什么的时候是的,答案是调试器

使用调试器查看代码正在做什么。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量,这是一个令人难以置信的学习工具。



调试器 - 维基百科,免费的百科全书 [ ^ ]

掌握Visual Studio 2010中的调试 - 初学者指南 [ ^ ]

使用Visual Studio 2010进行基本调试 - YouTube [ ^ ]



调试器在这里向您展示您的代码在做什么你的任务是与它应该做的事情进行比较。

调试器中没有魔法,它没有发现错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。


This is not helpful.

When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于如何比较visual basic中列表的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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