hi guys,

upon form load my datagridview is populated with data from an sql table. The datagridview has 3 columns Name, Amount and Cost. The Cost and Amount fields are have Zero as their default values. Whenever the user enters new values in those 2 fields i am using the row leave event of the datagridview to do a modulus on the amount against the cost.

The problem i am having is that the default values are being passed to the function and not the actual values entered by the user. I have enclosed my function and how i am getting the datagridview values. Any assistance would be grateful.

'below indicates how it is called
VerifyQuantity(DataGridViewRCC(1, i).Value, DataGridViewRCC(3, i).Value) 

 Function VerifyQuantity(ByVal a As Int64, ByVal b As Int16) As Boolean

        '@@@@@@@@@@@@ Designed by: Travis Ferreira @@@@@@@@@@
        '@@@@@@@@@@@@ Inputs:int64 and int16 @@@@@@@@@@ 
        '@@@@@@@@@@@@Return:Boolean @@@@@@@@ 
        '@@@@@@@@@@@@Purpose:Verifies that the quantities are of standard bundle sizes @@@@@@@ 

        Dim tempval As Int64
        tempval = a Mod b
        If tempval > 0 Then
            Return False
        Else
            Return True
        End If
    End Function

Are you testing the VerifyQuantity function or the values coming out of the DataGridView?

If you are testing the DGV, you could add a watch to "DataGridViewRCC(3, i).Value" to see what you're getting.
(...or even a MessageBox of the value)

If you are actually testing the VQ, maybe casting the Int16 to a long would help.

tempval = CLng(a) Mod CLng(b)

Edited 4 Years Ago by thines01: clarity

This article has been dead for over six months. Start a new discussion instead.