<p>Here is my function (<strong>updated</strong>):</p>

<pre><code>Public Shared Function shortenUrl(ByVal URL As String) As String
    Return shortenUrl(URL, 32)
End Function
Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String
    If URL.Length &gt; maxLength Then
        String.Format("{0}...{1}", URL.Substring(0, (maxLength / 2)), URL.Substring(URL.Length - ((maxLength / 2) - 3)))
    Else
        Return URL
    End If
End Function
</code></pre>

<p>I fixed the problem where it didn't return <code>maxLength</code> chars because it didn't take into account the ellipses.</p>

<hr>

<p>It seems to me that it is too complicated; any suggestions, comments, concerns are more than welcome.</p>

Why not do this?
```
```
Public Shared Function shortenUrl(ByVal URL As String) As String
    Return shortenUrl(URL, 29)
End Function
Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String
    If URL.Length > maxLength Then
        Return String.Format("{0}...{1}", URL.Substring(0, maxLength / 2),URL.Substring(URL.Length - (maxLength / 2)))
    Else
        Return URL
    End If
End Function
```
```
That at least gets rid of all of the tempoary declarations