If else语句的问题 [英] Problem With If else statement

查看:70
本文介绍了If else语句的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果else语句确实不是问题,但在我的情况下,我使用正则表达式和匹配集合来添加找到列表视图的匹配项,否则将值写入本地数据库但由于某种原因,else语句不能正常运行并将所有值写入我的本地数据库?..任何想法都被赞赏为什么它的写作都忽略了else语句。



If else statements are really not the issue but in my case I am using regular expressions and match collection to add matches found to a listview else write values to a local database but for some reason the else statement is not acting as it should and writes all values to my local database?.. any ideas are appreciated as to why its writing all but ignoring the else statement.

Dim matches1 As MatchCollection = Engine.CLAM_VIRUS_NAME.Matches(VReader)
    For Each Newmatch As Match In matches1
        For Each s As String In Subtract__List
            Dim Split_S() As String = Split(s, "|")
            Dim FS As String = Split_S(0)
            Dim OFP As String = Split_S(1)
            If M.Success = True AndAlso s.Contains(File_Name.Value) = True Then
                Add_Listview_Records(OFP, VN.Value, File_Name.Value, FS)
                For upIndex = ListView1.Items.Count - 1 To 1 Step -1
                    Dim upItem = ListView1.Items(upIndex)
                    For downIndex = 0 To upIndex - 1 Step 1
                        Dim downItem = ListView1.Items(downIndex)
                        If AreEquivalent(upItem, downItem) Then
                            ListView1.Items.Remove(upItem)
                            Exit For
                        End If
                    Next
                Next
            Else
                Engine.Insert_Access_Records(FS)
            End If
        Next
        Label8.Text = CStr(ListView1.Items.Count)
       VN = VN.NextMatch
        File_Name = File_Name.NextMatch
    Next Newmatch





我知道它必须有代码逻辑的东西,但是我尝试它仍然会写所有值而不是只有找不到的匹配项。



提前谢谢你!



I Know it must have something todo with the logic of the code but however I try it will still write all values instead of only the matches that are not found.

thank you in advance!

推荐答案

嗯...你的意思是

Um...did you mean
If M.Success = True AndAlso s.Contains(File_Name.Value) = True Then



鉴于M在你的任何一个循环中都没有改变。



如果不是解决它,您需要使用调试器逐步执行每一行,在每个语句执行之前计算出您期望发生的事情,并将其与实际结果进行比较。请记住,您可以随时查看每个变量的内容。当你发现一些不正确的东西......那么你可以仔细看看。



我们不能为你做到这一点 - 我们无法访问您的代码或数据。


Given that M doesn't change at all inside either of your loops.

If that doesn't solve it, you need to use the debugger to step through each line, working out what you expect to happen before each statement executes and comparing that against the actual results. Remember that you can look at the content of each variable as you go. When you find something that isn't right...then you can look more closely.

We can't do that for you - we don't have access to your code or your data.


Hi
试试这个如何使用断点并用值检查每一行

https://www.youtube.com/watch?v=w1777MupP_A [ ^ ]



如果else部分未激活意思是,你的如果部分满足价值。



或尝试以下方式检查



如果两者都必须为真,则使用此

Hi Try this how can use break point and checking each and every line with values
https://www.youtube.com/watch?v=w1777MupP_A[^]

If "else" part not active means,ur "If" part satisfy with values.

or try to following ways and check

if both must true then use this
If M.Success = True And s.Contains(File_Name.Value) = True Then



用于检查目的你将=改为<>并检查它到达其他部分


for checking purpose u change "=" to "<>" and check it reach else part

If M.Success <> True And s.Contains(File_Name.Value) <> True Then


这篇关于If else语句的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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