vb.net - How to sum values inserted in DataGridView cells in VB2010? -


i have problem on summing 2 values inserted in specific cells in dgv. process happen during run time. result of summing should display in specific cell.

i have tried code below:

    private sub dgdtax_cellcontentclick(byval sender system.object, byval e system.windows.forms.datagridviewcelleventargs) handles dgdtax.cellcontentclick      '======================================== calculation ==============================================='      'to calculate r4rm1     dim r2rm1 double     dim r3rm1 double      try         r2rm1 = cdbl(dgdtax(1, 2).value)     catch e1 exception         messagebox.show(e1.message)         exit sub     end try      try         r3rm1 = cdbl(dgdtax(1, 3).value)     catch e2 exception         messagebox.show(e2.message)         exit sub     end try      dgdtax(1, 4).value = r2rm1 + r3rm1  end sub 

but didnt work. shows message error "conversion type dbnull type double not valid."

what should do?

i suspect dgdtax(1,2).value or dgdtax(1,3).value null in database. apologies, don't know vb syntax off hand in c# test value not of type dbnull e.g

if (!(dgdtax(1,2).value dbnull)) {  // stuff  } 

taking stab @ vb

if not dgdtax(1,2).value dbnull //do stuff end if 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -