Shandy's Blog

Where Andrew Sutton, aka Shandy rants and rambles on as the fancy takes him

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

My name is Andrew Sutton, aka Shandy.

I am currently living and working in the UK within the garment industry as an IT specialist. This blog contains mainly IT related issues.

I was a Microsoft VB MVP for a couple of years (Apr 2004-Mar 2006) and was a vbCityLeader between April 2003 and June 2007.

If you are looking for my Sri Lanka or Morocco experiences check out Shandy's Sri Lanka Blog or Shandy's Morocco Blog.

JulAugust 2008Sep
SMTWTFS
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

Articles

Archives

Topics

Image Galleries

.NET

Blogs I Read

Others

VB.Classic

I noticed this post at vbCity and after looking at the code wondered if I could come up with a more compact solution and I think I have.

Private Function FindNumberOfUniqueCharactersInString(ByVal strVvText As String _
                                                     , ByVal blnVvCaseSensitive As Boolean _
                                                     ) As Integer
    Dim intLvIndex As Integer
    Dim intLvCount As Integer: intLvCount = 1
    strVvText = IIf(blnVvCaseSensitive, strVvText, UCase$(strVvText))
    For intLvIndex = 2 To Len(strVvText)
        If InStr(Left(strVvText, intLvIndex - 1) _
                , Mid(strVvText, intLvIndex, 1) _
                ) = 0 Then
            intLvCount = intLvCount + 1
        End If
    Next
    FindNumberOfUniqueCharactersInString = intLvCount
End Function

There are possibly even more compact and elegant solutions to this interesting little issue but I quite like my solution :)

posted on Friday, July 15, 2005 2:45 PM