larris
Member
- Joined
- Mar 13, 2006
- Messages
- 23
- Programming Experience
- 1-3
Hallo to all!!
what i want is to simulate the oracle nvl function into vb2005
I have an access database. Here is the code i wrote witch it doesnt work
Public Function nvl(ByVal nLong, ByVal nref) As Object
If (nLong) Is Nothing Then
nvl = nref
Else
nvl = nLong
End If
End Function
private sub ypol_mikta()
Dim row As DataGridViewRow
Dim mikta As Single
For Each row In datagridview1.Rows
mikta = nvl(row.Cells("mikta").Value, 0)
MsgBox(mikta)
Next
This is my test code.The datagridview1 is already populated with values.When i run the code the msgbox shows the first rows that have values but when the row has a null value it raises the anhandled exception
"cannot convert a dbnull value to single"
what did i do wrong???
what i want is to simulate the oracle nvl function into vb2005
I have an access database. Here is the code i wrote witch it doesnt work
Public Function nvl(ByVal nLong, ByVal nref) As Object
If (nLong) Is Nothing Then
nvl = nref
Else
nvl = nLong
End If
End Function
private sub ypol_mikta()
Dim row As DataGridViewRow
Dim mikta As Single
For Each row In datagridview1.Rows
mikta = nvl(row.Cells("mikta").Value, 0)
MsgBox(mikta)
Next
This is my test code.The datagridview1 is already populated with values.When i run the code the msgbox shows the first rows that have values but when the row has a null value it raises the anhandled exception
"cannot convert a dbnull value to single"
what did i do wrong???