Look, I have the following problem, I am doing a program in vb.net that reads a book and analyzes how many sheets it has, columns, types and detects errors in terms of type (for example, if there is a data in a cell of type text within a numerical column). I'm having problems with the data type "date" because for example, if in a date column is a text type data, the program returns that box as empty (DBNull), I did the tests with msgBox and discovered such thing .
What I want to achieve is that when I detect an error (or DBNull) in the columns with dates, it returns the address of the cell where it is currently (If in C10, C40, C2, C2223 ... ETC ), this would serve me a million since I only pass as parameter the address of the cell to my substitution method and I would achieve what I want. That's right now my error detection function (No interop references currently) ...
Protected Friend Function obtenerErroresColumna(ByVal columna As String, ByVal hoja As String, ByVal tipo As String) As Integer
If (Not String.IsNullOrEmpty(columna)) Then
Dim cmd As String = "Select [" & columna & "] from [" & hoja & "$]"
Dim errores As Integer = 0
Dim celdas As Integer = 1
Dim tabla As New DataTable
Try
Dim adapter As New OleDbDataAdapter(cmd, conexion)
adapter.Fill(tabla)
adapter.Dispose()
For Each itm In tabla.Rows
celdas += 1
If (tipo.Equals("Cadena")) Then
If (Not IsDBNull(itm(0))) Then
If (IsNumeric(itm(0))) Then
errores += 1
setValoresError = itm(0)
End If
End If
ElseIf (tipo.Equals("Numerico")) Then
If (Not IsDBNull(itm(0))) Then
If (Not IsNumeric(itm(0))) Then
errores += 1
setValoresError = itm(0)
End If
End If
ElseIf (tipo.Equals("Fecha")) Then
If (Not IsDBNull(itm(0))) Then
If (Not IsDate(itm(0))) Then
errores += 1
setValoresError = itm(0)
End If
End If
End If
Next
tabla.Dispose()
Return errores
Catch ex As Exception
cajaMensaje("Error inesperado", ex.Message, My.Resources._error).ShowDialog()
PantallaPrincipal.lbldireccion.ForeColor = Color.Red
Return errores
End Try
Else
Return 0
End If
End Function
If you know any way to get that? ...