Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27333

VS 2010 Not handling IF statement comparisons properly

$
0
0
I have a particular sub routine in VS 2010 that does not seem to be performing the comparisons in IF statement conditions properly. During debugging it seems to skip some entirely. A fellow developer and I have been looking at them for the past day or so and it seems like it should work just fine (they arent that complicated). I am hoping we are just burnt out and missing something obvious...

In particular, it seems to fail when comparing strings. I had a FOR EACH loop that was comparing column values in a datatable, but it seemed like when I used the .ToString method it wouldnt ever trigger a match when comparing a .ToString item from a DataRow to a string value constant. So I had to make separate string variables and initialize them to items from the DataRow and THEN use those variables in the IF statement condition.

Now I am facing another problem in the same sub routine where the IF statement condition wont even be processed. I have set BREAK points around the entire section of code, and it doesnt ever seem to trigger and break on specific conditions.


For some addition Info the SubmitRequest() function returns the string of "success" when performed correctly.

The condition that never triggers is:
Code:

Result = SubmitRequest(TestPhoneHome, TestZipCode)
If Result = "success" Then                           
        UpdateRpvLog(TestFLID, "home", "submit", Date.Now.ToString)
Else


Any help would be GREATLY appreciated! thanks!!!



See below code:
Code:

Private Sub RpvProcess()
        Dim Result As String = ""
        'For some reason Visual Studio would NOT correctly compare values from dr.item("<ColumnName>").ToString = "<String Expression>" properly - 2013-03-11
        Dim TestFLID As String = ""
        Dim TestPhoneMobile As String = ""
        Dim TestPhoneHome As String = ""
        Dim TestMPhoneSubmitDate As String = ""
        Dim TestMPhoneResultDate As String = ""
        Dim TestMPhoneResult As String = ""
        Dim TestHPhoneSubmitDate As String = ""
        Dim TestHPhoneResultDate As String = ""
        Dim TestHPhoneResult As String = ""
        Dim TestZipCode As String = ""



        'TEMPORARILY DISABLED until loop issue resolved. do not want new records added.
        'For Each dr0 As DataRow In RetrievePhones().Rows
        '    If InsertRpvLogStart(dr0.Item("FinanceLeadID"), dr0.Item("PhoneMobile"), dr0.Item("PhoneHome"), dr0.Item("ZipCode")) = False Then
        '        WriteToLog("Failed to insert new record into tRpvLog")
        '        GoTo EndOfCheck
        '    End If
        'Next








        '////////Submitting phone number
        For Each dr As DataRow In RetrieveRpvPhones().Rows
            TestFLID = Trim(dr.Item("FinanceLeadID").ToString)
            TestPhoneMobile = Trim(dr.Item("PhoneMobile").ToString)
            TestPhoneHome = Trim(dr.Item("PhoneHome").ToString)
            TestMPhoneSubmitDate = Trim(dr.Item("MPhoneSubmitDate").ToString)
            TestMPhoneResultDate = Trim(dr.Item("MPhoneResultDate").ToString)
            TestMPhoneResult = Trim(dr.Item("MPhoneResult").ToString)
            TestHPhoneSubmitDate = Trim(dr.Item("HPhoneSubmitDate").ToString)
            TestHPhoneResultDate = Trim(dr.Item("HPhoneResultDate").ToString)
            TestHPhoneResult = Trim(dr.Item("HPhoneResult").ToString)
            TestZipCode = Trim(dr.Item("ZipCode").ToString)


            'see if Mobile phone is formatted correctly


            If IsNumeric(TestPhoneMobile) = False Or TestPhoneMobile.Length <> 10 Or TestMPhoneResult = "disconnected" Then


                '******HOME PHONE **************
                'set Mobile Phone Submit Result to "disconnected" if it fails general formatting
                If TestMPhoneResult <> "disconnected" Then UpdateRpvLog(TestFLID, "mobile", "submit", , "disconnected")

                'set Home Phone Submit Result to "disconnected" if it fails general formatting
                If IsNumeric(TestPhoneHome) = False Or TestPhoneHome.Length <> 10 Then
                    UpdateRpvLog(TestFLID, "home", "submit", , "disconnected")
                Else

                    'check if number was already submitted
                    If TestHPhoneSubmitDate = "" And TestHPhoneResult <> "disconnected" Then
                        Result = ""
                        Result = SubmitRequest(TestPhoneHome, TestZipCode)

                        If Result = "success" Then
                            UpdateRpvLog(TestFLID, "home", "submit", Date.Now.ToString)
                        Else
                            WriteToLog("FinanceLeadID - " & TestFLID & " : Home Phone =PUT= returned: " & Result)
                        End If
                    End If
                    'END of check if number was already submitted


                End If
                '******END OF HOME PHONE *******
            Else

                '******MOBILE PHONE ************
                'check if number was already submitted
                If TestMPhoneSubmitDate = "" And TestMPhoneResult <> "disconnected" Then
                    Result = ""
                    Result = SubmitRequest(TestPhoneMobile, TestZipCode)
                    If Result = "success" Then
                        UpdateRpvLog(TestFLID, "mobile", "submit", Date.Now.ToString)
                    Else
                        WriteToLog("FinanceLeadID - " & TestFLID & " : Mobile Phone =PUT= returned: " & Result)
                    End If

                End If
                '******END OF MOBILE PHONE *****
            End If



        Next
        '//////// End of submit


        'Catch ex As Exception
        '    'TODO: finish exception handling. duplicate exception handling on the GET as well.
        'End Try






        '////////Get phone number status
        For Each dr As DataRow In RetrieveRpvPhones().Rows

            TestFLID = Trim(dr.Item("FinanceLeadID").ToString)
            TestPhoneMobile = Trim(dr.Item("PhoneMobile").ToString)
            TestPhoneHome = Trim(dr.Item("PhoneHome").ToString)
            TestMPhoneSubmitDate = Trim(dr.Item("MPhoneSubmitDate").ToString)
            TestMPhoneResultDate = Trim(dr.Item("MPhoneResultDate").ToString)
            TestMPhoneResult = Trim(dr.Item("MPhoneResult").ToString)
            TestHPhoneSubmitDate = Trim(dr.Item("HPhoneSubmitDate").ToString)
            TestHPhoneResultDate = Trim(dr.Item("HPhoneResultDate").ToString)
            TestHPhoneResult = Trim(dr.Item("HPhoneResult").ToString)
            TestZipCode = Trim(dr.Item("ZipCode").ToString)

            If TestMPhoneResult = "disconnected" Then


                '******HOME PHONE **************

                '--see if home phone has already been checked
                If TestHPhoneResult = "" Then

                    Result = ""
                    Result = CheckResult(TestPhoneHome, TestZipCode)

                    If Result = "connected" Or Result = "disconnected" Then
                        UpdateRpvLog(TestFLID, "home", "check", Date.Now.ToString, Result)
                    Else
                        WriteToLog("FinanceLeadID - " & TestFLID & " : Home Phone =GET= returned: " & Result)
                    End If


                End If
                '******END OF HOME PHONE *******
            Else

                '******MOBILE PHONE ************
                '--see if mobile phone has already been checked
                If TestMPhoneResult = "" Then

                    Result = ""
                    Result = CheckResult(TestPhoneMobile, TestZipCode)

                    If Result = "connected" Or Result = "disconnected" Then
                        UpdateRpvLog(TestFLID, "mobile", "check", Date.Now.ToString, Result)
                    Else
                        WriteToLog("FinanceLeadID - " & TestFLID & " : Mobile Phone =GET= returned: " & Result)
                    End If


                End If
                '******END OF MOBILE PHONE *****
            End If



        Next
        '//////// End of get status





       




EndOfCheck:
    End Sub


Viewing all articles
Browse latest Browse all 27333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>