An useful article/code for joining DataTables

J

Jim Hughes

I really wish that ALL published VB.Net code (Especially Microsoft's) was
required to use Option Strict

I was able to modify all of the occurrences of Split to use Convert.ToChar
in JoinView.vb (the download in the link posted by Miha)

e.g. Fields() As String = FieldList.Split(",") to Fields() As String =
FieldList.Split(Convert.ToChar(","))

But the one function that I could not figure out how to modify for Option
Strict is CompareValues

Error: "Option Strict On disallows operands of type Object for operator '='.
Use the 'Is' operator to test for object identity."

Error occurs on the ElseIf lines.

Private Function CompareValues(ByVal x As Object, ByVal y As Object) As
Integer
'
' Compares two objects and takes DBNull.Value into account.
DBNull.Value is smaller than
' any other value.
'
If x Is DBNull.Value Then
If y Is DBNull.Value Then
Return 0
Else
Return -1
End If
Else
If y Is DBNull.Value Then
Return 1
ElseIf x < y Then
Return -1
ElseIf x = y Then
Return 0
Else
Return 1
End If
End If
End Function

I read the docs at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vagrpcomparison.asp
and know about TypeName, Is TypeOf and Ctype/DirectCast...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top