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

Bug in VB code

$
0
0
Reed, thanks for your help!  However, I'm still puzzled.  I've added a copy of the code I normally use when updating an instance, opposed to adding/creating a new instance, and I've never encountered this problem before.  I NEVER use structures, never had a need to, therefore I always use Classes. Normally, I have a line of code following the two lines: Dim newUnite AS New Unite AND newUnite = New Unite which is: newUnit = unitePass.  This way I don't have to move all the variables to newUnite, only the ones that changed.  My question is why did I get bit here? The code that now works, thanks to you follows:
    Private Sub ProcessEditUniteInstance()
        Dim newUnite As New Unite
        newUnite = New Unite
        PopulateEditUniteInstance(newUnite)
        Try
            UniteDB.UpdateUnite(unitePass, _
                                newUnite)
            unitePass = newUnite
        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

    Private Sub PopulateEditUniteInstance(ByRef unite As Unite)
        'NOTE: These will always be selected, whether they are or not in the cbo's,
        '      because their key selected items were all set to true and their key
        '      holds were set in SetIndexForComboBoxes. If they are set in the
        '      appropriate ComboBox, the new selection will replace the one set in
        '      SetIndexForComboBoxes.
        unite.KeyGroup = unitePass.KeyGroup
        unite.KeyRecipe = unitePass.KeyRecipe
        unite.KeyFood = keyFoodHold
        unite.KeyNbr = keyNumberOfHold
        unite.KeySize = keySizeOfHold
        unite.KeyAction = keyActionHold
    End Sub


Terry 01



Viewing all articles
Browse latest Browse all 6

Trending Articles



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