Click here to Skip to main content
15,918,211 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an object that I'm trying to reference but I get the error:
Option Strict disallows late binding

In the code below, the underlined object is what causes the error

Public Sub Sort(contacts As Object, comparer As Object, fieldName As String, direction As String)
       Dim itemIndex As Integer = 0

       Select Case fieldName
           Case "FirstName"
               If direction = "decend" Then
                   comparer = serializeInfo.OrderByDescending(Function(x) x.FirstName).ToList()
                   For itemIndex = 0 To serializeInfo.Count - 1
                       Console.WriteLine(comparer(itemIndex).FirstName)
                   Next
               Else
                   comparer = serializeInfo.OrderBy(Function(x) x.FirstName).ToList()
               End If


I can't get preview to work so I'm leaving the code as is.
thanks for any help.

What I have tried:

Some casting
Create object
Posted
Updated 14-May-16 2:56am
v6
Comments
Karthik_Mahalingam 14-May-16 8:12am    
what is comparer type ?
jumper777 14-May-16 8:51am    
serializeInfo = serializeInfo As New List(Of Contact)()

Contact contains: FirstName, LastName, etc
Karthik_Mahalingam 14-May-16 8:57am    
check the solution and tell if it works.
jumper777 14-May-16 8:55am    
Hey... I just got it to work. Your question helped me to fix it.

thank you
Karthik_Mahalingam 14-May-16 8:58am    
oh cool

1 solution

try this

VB.NET
Public Sub Sort(contacts As Object, comparer As List(Of Contact), fieldName As String, direction As String)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900