Comparing value from a cell in one datagridview to another












-1















first of all, following is my codes:



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'Establish connection with sql server. Fill the data in data grid view (dgvData)

For i As Integer = 2 To dgvData.Columns.Count() - 1

dgvSettings.Rows.Add(dgvData.Columns(i).HeaderText, 0, 100, "High")

Next

End Sub

Public Sub comparevalues()

For z As Integer = 2 To dgvData.ColumnCount - 1

If dgvData.Rows(0).Cells(z).Value.ToString() > dgvSettings.Rows(z - 2).Cells(2).Value.ToString() Then

MsgBox("Value Exceed Maximum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

ElseIf dgvData.Rows(0).Cells(z).Value.ToString() < dgvSettings.Rows(z - 2).Cells(1).Value.ToString() Then

MsgBox("Value Below Minimum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

Else
'in range, do nothing
End If
Next

End Sub


this is dgvdata table, it is linked to my sql server db



this is dgvalert table, any values from latest row in dgvdata that meets the condition as in comparevalues() will be tabulated here.



this is dgvsettings table, the limit conditions are all set in here.



so here is what i'm trying to do, although some of you might be able to interpret from the code given above. After filling up the dgvData with my sql data table, i'd like to compare the values in each columns of the latest row as according to the condition set in the comparevalues() sub. ie. if a value in, lets say column pH, exceeds the value limit set in the dgvSettings, then it will then added into the dgvAlert table.



but the problem is, when i run the code, those within the range set in the dgvSettings are still added into the dgvAlert. and most of them are taken as exceeded the limit when it should be still in the range limit. i've been cracking my head since the past few days trying to get it right. Your help is much appreciated. Thank you.










share|improve this question

























  • Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

    – jmcilhinney
    Nov 25 '18 at 15:06











  • @jmcilhinney My apology for that. I've fixed it now. Thank you.

    – Shakree Elmi
    Nov 25 '18 at 15:13











  • why are you comparing strings with < and > ?

    – preciousbetine
    Nov 25 '18 at 17:35











  • @preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

    – Shakree Elmi
    Nov 26 '18 at 2:03
















-1















first of all, following is my codes:



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'Establish connection with sql server. Fill the data in data grid view (dgvData)

For i As Integer = 2 To dgvData.Columns.Count() - 1

dgvSettings.Rows.Add(dgvData.Columns(i).HeaderText, 0, 100, "High")

Next

End Sub

Public Sub comparevalues()

For z As Integer = 2 To dgvData.ColumnCount - 1

If dgvData.Rows(0).Cells(z).Value.ToString() > dgvSettings.Rows(z - 2).Cells(2).Value.ToString() Then

MsgBox("Value Exceed Maximum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

ElseIf dgvData.Rows(0).Cells(z).Value.ToString() < dgvSettings.Rows(z - 2).Cells(1).Value.ToString() Then

MsgBox("Value Below Minimum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

Else
'in range, do nothing
End If
Next

End Sub


this is dgvdata table, it is linked to my sql server db



this is dgvalert table, any values from latest row in dgvdata that meets the condition as in comparevalues() will be tabulated here.



this is dgvsettings table, the limit conditions are all set in here.



so here is what i'm trying to do, although some of you might be able to interpret from the code given above. After filling up the dgvData with my sql data table, i'd like to compare the values in each columns of the latest row as according to the condition set in the comparevalues() sub. ie. if a value in, lets say column pH, exceeds the value limit set in the dgvSettings, then it will then added into the dgvAlert table.



but the problem is, when i run the code, those within the range set in the dgvSettings are still added into the dgvAlert. and most of them are taken as exceeded the limit when it should be still in the range limit. i've been cracking my head since the past few days trying to get it right. Your help is much appreciated. Thank you.










share|improve this question

























  • Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

    – jmcilhinney
    Nov 25 '18 at 15:06











  • @jmcilhinney My apology for that. I've fixed it now. Thank you.

    – Shakree Elmi
    Nov 25 '18 at 15:13











  • why are you comparing strings with < and > ?

    – preciousbetine
    Nov 25 '18 at 17:35











  • @preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

    – Shakree Elmi
    Nov 26 '18 at 2:03














-1












-1








-1








first of all, following is my codes:



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'Establish connection with sql server. Fill the data in data grid view (dgvData)

For i As Integer = 2 To dgvData.Columns.Count() - 1

dgvSettings.Rows.Add(dgvData.Columns(i).HeaderText, 0, 100, "High")

Next

End Sub

Public Sub comparevalues()

For z As Integer = 2 To dgvData.ColumnCount - 1

If dgvData.Rows(0).Cells(z).Value.ToString() > dgvSettings.Rows(z - 2).Cells(2).Value.ToString() Then

MsgBox("Value Exceed Maximum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

ElseIf dgvData.Rows(0).Cells(z).Value.ToString() < dgvSettings.Rows(z - 2).Cells(1).Value.ToString() Then

MsgBox("Value Below Minimum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

Else
'in range, do nothing
End If
Next

End Sub


this is dgvdata table, it is linked to my sql server db



this is dgvalert table, any values from latest row in dgvdata that meets the condition as in comparevalues() will be tabulated here.



this is dgvsettings table, the limit conditions are all set in here.



so here is what i'm trying to do, although some of you might be able to interpret from the code given above. After filling up the dgvData with my sql data table, i'd like to compare the values in each columns of the latest row as according to the condition set in the comparevalues() sub. ie. if a value in, lets say column pH, exceeds the value limit set in the dgvSettings, then it will then added into the dgvAlert table.



but the problem is, when i run the code, those within the range set in the dgvSettings are still added into the dgvAlert. and most of them are taken as exceeded the limit when it should be still in the range limit. i've been cracking my head since the past few days trying to get it right. Your help is much appreciated. Thank you.










share|improve this question
















first of all, following is my codes:



Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

'Establish connection with sql server. Fill the data in data grid view (dgvData)

For i As Integer = 2 To dgvData.Columns.Count() - 1

dgvSettings.Rows.Add(dgvData.Columns(i).HeaderText, 0, 100, "High")

Next

End Sub

Public Sub comparevalues()

For z As Integer = 2 To dgvData.ColumnCount - 1

If dgvData.Rows(0).Cells(z).Value.ToString() > dgvSettings.Rows(z - 2).Cells(2).Value.ToString() Then

MsgBox("Value Exceed Maximum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

ElseIf dgvData.Rows(0).Cells(z).Value.ToString() < dgvSettings.Rows(z - 2).Cells(1).Value.ToString() Then

MsgBox("Value Below Minimum Limit")

dgvAlert.Rows.Add(False, dgvData.Rows(0).Cells(1).Value.ToString(), dgvData.Columns(z).HeaderText.ToString(), dgvData.Rows(0).Cells(z).Value.ToString(), "Unacknowledged", dgvSettings.Rows(z - 2).Cells(3).Value.ToString())

Else
'in range, do nothing
End If
Next

End Sub


this is dgvdata table, it is linked to my sql server db



this is dgvalert table, any values from latest row in dgvdata that meets the condition as in comparevalues() will be tabulated here.



this is dgvsettings table, the limit conditions are all set in here.



so here is what i'm trying to do, although some of you might be able to interpret from the code given above. After filling up the dgvData with my sql data table, i'd like to compare the values in each columns of the latest row as according to the condition set in the comparevalues() sub. ie. if a value in, lets say column pH, exceeds the value limit set in the dgvSettings, then it will then added into the dgvAlert table.



but the problem is, when i run the code, those within the range set in the dgvSettings are still added into the dgvAlert. and most of them are taken as exceeded the limit when it should be still in the range limit. i've been cracking my head since the past few days trying to get it right. Your help is much appreciated. Thank you.







vb.net datagridview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 15:17







Shakree Elmi

















asked Nov 25 '18 at 14:52









Shakree ElmiShakree Elmi

33




33













  • Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

    – jmcilhinney
    Nov 25 '18 at 15:06











  • @jmcilhinney My apology for that. I've fixed it now. Thank you.

    – Shakree Elmi
    Nov 25 '18 at 15:13











  • why are you comparing strings with < and > ?

    – preciousbetine
    Nov 25 '18 at 17:35











  • @preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

    – Shakree Elmi
    Nov 26 '18 at 2:03



















  • Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

    – jmcilhinney
    Nov 25 '18 at 15:06











  • @jmcilhinney My apology for that. I've fixed it now. Thank you.

    – Shakree Elmi
    Nov 25 '18 at 15:13











  • why are you comparing strings with < and > ?

    – preciousbetine
    Nov 25 '18 at 17:35











  • @preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

    – Shakree Elmi
    Nov 26 '18 at 2:03

















Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

– jmcilhinney
Nov 25 '18 at 15:06





Why is your indenting all over the place? Making code harder to read is not the best way to get people to help you with it. Given that VS can maintain proper code formatting for you, there's really no excuse for not posting properly formatted code.

– jmcilhinney
Nov 25 '18 at 15:06













@jmcilhinney My apology for that. I've fixed it now. Thank you.

– Shakree Elmi
Nov 25 '18 at 15:13





@jmcilhinney My apology for that. I've fixed it now. Thank you.

– Shakree Elmi
Nov 25 '18 at 15:13













why are you comparing strings with < and > ?

– preciousbetine
Nov 25 '18 at 17:35





why are you comparing strings with < and > ?

– preciousbetine
Nov 25 '18 at 17:35













@preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

– Shakree Elmi
Nov 26 '18 at 2:03





@preciousbetine i must've stated it wrongly. What I meant was to check whether that one cell is < or > than the other cell..

– Shakree Elmi
Nov 26 '18 at 2:03












2 Answers
2






active

oldest

votes


















1














You are writing it wrong.



You have to convert those strings to actual numbers first if you want to compare them.



Public Sub comparevalues()
For z= 2 To dgvData.ColumnCount - 1
Dim Cell1 as Double = CDbl(dgvData(z,0).Value.ToString)
Dim Cell2 as Double = CDbl(dgvSettings(2,z-2).Value.ToString)
Dim Cell3 as Double = CDbl(dgvSettings(1,z-2).Value.ToString)

If Cell1 > Cell2 Then
MsgBox("Value Exceed Maximum Limit")
dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
ElseIf Cell1 < Cell3 Then
MsgBox("Value Below Minimum Limit")
dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
Else
'in range, do nothing
End If
Next
End Sub





share|improve this answer


























  • It appears that many of the columns include decimal points so Integer is not going to work.

    – Mary
    Nov 25 '18 at 21:17











  • Thank you so much for this! It works like a charm. Very much appreciated.

    – Shakree Elmi
    Nov 26 '18 at 2:02



















0














Try the following to see why comparing strings with < and > does not work for your case.



Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim x As String = "7".ToString
Dim y As String = "10".ToString
If x > y Then
MessageBox.Show("7 is greater than 10")
ElseIf x < y Then
MessageBox.Show("10 is greater than 7")
End If
End Sub


Get rid of the .ToString






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468708%2fcomparing-value-from-a-cell-in-one-datagridview-to-another%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You are writing it wrong.



    You have to convert those strings to actual numbers first if you want to compare them.



    Public Sub comparevalues()
    For z= 2 To dgvData.ColumnCount - 1
    Dim Cell1 as Double = CDbl(dgvData(z,0).Value.ToString)
    Dim Cell2 as Double = CDbl(dgvSettings(2,z-2).Value.ToString)
    Dim Cell3 as Double = CDbl(dgvSettings(1,z-2).Value.ToString)

    If Cell1 > Cell2 Then
    MsgBox("Value Exceed Maximum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    ElseIf Cell1 < Cell3 Then
    MsgBox("Value Below Minimum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    Else
    'in range, do nothing
    End If
    Next
    End Sub





    share|improve this answer


























    • It appears that many of the columns include decimal points so Integer is not going to work.

      – Mary
      Nov 25 '18 at 21:17











    • Thank you so much for this! It works like a charm. Very much appreciated.

      – Shakree Elmi
      Nov 26 '18 at 2:02
















    1














    You are writing it wrong.



    You have to convert those strings to actual numbers first if you want to compare them.



    Public Sub comparevalues()
    For z= 2 To dgvData.ColumnCount - 1
    Dim Cell1 as Double = CDbl(dgvData(z,0).Value.ToString)
    Dim Cell2 as Double = CDbl(dgvSettings(2,z-2).Value.ToString)
    Dim Cell3 as Double = CDbl(dgvSettings(1,z-2).Value.ToString)

    If Cell1 > Cell2 Then
    MsgBox("Value Exceed Maximum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    ElseIf Cell1 < Cell3 Then
    MsgBox("Value Below Minimum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    Else
    'in range, do nothing
    End If
    Next
    End Sub





    share|improve this answer


























    • It appears that many of the columns include decimal points so Integer is not going to work.

      – Mary
      Nov 25 '18 at 21:17











    • Thank you so much for this! It works like a charm. Very much appreciated.

      – Shakree Elmi
      Nov 26 '18 at 2:02














    1












    1








    1







    You are writing it wrong.



    You have to convert those strings to actual numbers first if you want to compare them.



    Public Sub comparevalues()
    For z= 2 To dgvData.ColumnCount - 1
    Dim Cell1 as Double = CDbl(dgvData(z,0).Value.ToString)
    Dim Cell2 as Double = CDbl(dgvSettings(2,z-2).Value.ToString)
    Dim Cell3 as Double = CDbl(dgvSettings(1,z-2).Value.ToString)

    If Cell1 > Cell2 Then
    MsgBox("Value Exceed Maximum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    ElseIf Cell1 < Cell3 Then
    MsgBox("Value Below Minimum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    Else
    'in range, do nothing
    End If
    Next
    End Sub





    share|improve this answer















    You are writing it wrong.



    You have to convert those strings to actual numbers first if you want to compare them.



    Public Sub comparevalues()
    For z= 2 To dgvData.ColumnCount - 1
    Dim Cell1 as Double = CDbl(dgvData(z,0).Value.ToString)
    Dim Cell2 as Double = CDbl(dgvSettings(2,z-2).Value.ToString)
    Dim Cell3 as Double = CDbl(dgvSettings(1,z-2).Value.ToString)

    If Cell1 > Cell2 Then
    MsgBox("Value Exceed Maximum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    ElseIf Cell1 < Cell3 Then
    MsgBox("Value Below Minimum Limit")
    dgvAlert.Rows.Add(False, dgvData(1,0).Value.ToString, dgvData.Columns(z).HeaderText.ToString(), dgvData(z,0).Value.ToString, "Unacknowledged", dgvSettings(3,z-2).Value.ToString)
    Else
    'in range, do nothing
    End If
    Next
    End Sub






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 26 '18 at 2:07

























    answered Nov 25 '18 at 20:40









    CruleDCruleD

    515138




    515138













    • It appears that many of the columns include decimal points so Integer is not going to work.

      – Mary
      Nov 25 '18 at 21:17











    • Thank you so much for this! It works like a charm. Very much appreciated.

      – Shakree Elmi
      Nov 26 '18 at 2:02



















    • It appears that many of the columns include decimal points so Integer is not going to work.

      – Mary
      Nov 25 '18 at 21:17











    • Thank you so much for this! It works like a charm. Very much appreciated.

      – Shakree Elmi
      Nov 26 '18 at 2:02

















    It appears that many of the columns include decimal points so Integer is not going to work.

    – Mary
    Nov 25 '18 at 21:17





    It appears that many of the columns include decimal points so Integer is not going to work.

    – Mary
    Nov 25 '18 at 21:17













    Thank you so much for this! It works like a charm. Very much appreciated.

    – Shakree Elmi
    Nov 26 '18 at 2:02





    Thank you so much for this! It works like a charm. Very much appreciated.

    – Shakree Elmi
    Nov 26 '18 at 2:02













    0














    Try the following to see why comparing strings with < and > does not work for your case.



    Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim x As String = "7".ToString
    Dim y As String = "10".ToString
    If x > y Then
    MessageBox.Show("7 is greater than 10")
    ElseIf x < y Then
    MessageBox.Show("10 is greater than 7")
    End If
    End Sub


    Get rid of the .ToString






    share|improve this answer




























      0














      Try the following to see why comparing strings with < and > does not work for your case.



      Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Dim x As String = "7".ToString
      Dim y As String = "10".ToString
      If x > y Then
      MessageBox.Show("7 is greater than 10")
      ElseIf x < y Then
      MessageBox.Show("10 is greater than 7")
      End If
      End Sub


      Get rid of the .ToString






      share|improve this answer


























        0












        0








        0







        Try the following to see why comparing strings with < and > does not work for your case.



        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim x As String = "7".ToString
        Dim y As String = "10".ToString
        If x > y Then
        MessageBox.Show("7 is greater than 10")
        ElseIf x < y Then
        MessageBox.Show("10 is greater than 7")
        End If
        End Sub


        Get rid of the .ToString






        share|improve this answer













        Try the following to see why comparing strings with < and > does not work for your case.



        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim x As String = "7".ToString
        Dim y As String = "10".ToString
        If x > y Then
        MessageBox.Show("7 is greater than 10")
        ElseIf x < y Then
        MessageBox.Show("10 is greater than 7")
        End If
        End Sub


        Get rid of the .ToString







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 19:30









        MaryMary

        3,5912819




        3,5912819






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53468708%2fcomparing-value-from-a-cell-in-one-datagridview-to-another%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python