You are not returning the value if the Invoke is required.
Try this instead:
Private Delegate Function TextLengthDelegate(tb As TextBox) As Integer
Private Function TextLength(tb As TextBox) As Integer
If tb.InvokeRequired Then
Return CInt(tb.Invoke(New TextLengthDelegate(AddressOf TextLength), tb))
Else
Return tb.TextLength
End If
End Function
However, you might find this code easier as you don't have to define a separate delegate:
Private Function TextLength(tb As TextBox) As Integer
If tb.InvokeRequired Then
Return CType(tb.Invoke(New Action(Of TextBox)(AddressOf TextLength), tb), Integer)
Else
Return tb.TextLength
End If
End Function