Quantcast
Channel: Bug in VB code
Viewing all articles
Browse latest Browse all 6

Bug in VB code

$
0
0

I've encountered a problems getting the following basic code to work, and it or something similar has worked many times before.  I've cut the code down to the minimal basic to make it easier to relate the problem to you.

PROBLEM: unitePass gets changed when it shouldn't. The code follows:

    Private Sub ProcessEditUniteInstance()
        Dim unite As New Unite
        unite = New Unite   ' consists of 6 integer variables, all = 0
        '
        unite = unitePass       ' here: unitePass values = 3,1,3,10,1,2
        'PopulateEditUniteInstance(newUnite)
        unite.KeyFood = keyFoodHold         '   3
        unite.KeyNbr = keyNumberOfHold      '   1
        unite.KeySize = keySizeOfHold       '   1
        unite.KeyAction = keyActionHold     '   2
        Try
            '                   unitePass value here = 3,1,3,1,1,2                        
            UniteDB.UpdateUnite(unitePass, _
                                unite)
            '                   unite     value here = 3,1,3,1,1,2 
            unitePass = unite
        Catch ex As ArgumentException
            MessageBox.Show(ex.Message, "Argument Exception")
        Catch ex As DataException
            MessageBox.Show(ex.Message, ex.GetType.ToString)
        Catch ex As SqlException
            MessageBox.Show("SQL Exception # " & ex.Number & ": " & _
                             ex.Message, ex.GetType.ToString)
        End Try
    End Sub
The comments show the values before and after the code executes. As a result, the update doesn't work, and I can't update any unite instances.

Terry 01


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images