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. My personal (Non IT) blog is now at Shandy's Place

JunJuly 2005Aug
SMTWTFS
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

Articles

Archives

Topics

Image Galleries

.NET

Blogs I Read

Others

VB.Classic

Wednesday, July 20, 2005 #

I just received an email to inform me that fixpack 4 has been released by AxTools.
posted @ 11:51 PM

Whilst wandering the internet I came across the following annoucement, Oracle Developer Tools for Visual Studio .NET. It looks like Oracle have made some goodies available free of charge for VS.NET.
posted @ 9:53 PM

This post at vbCity piqued my interest today. I got a bit carried away with providing a solution. In retrospect I think that the use of a simple left$ statement would have solved the member's problem. Anyhow the idea of removing duplicate words from a string appealed to me and after re-working my rather bloated code I came up with the following solution:

Private Function RemoveDuplicateWords(ByVal strVvText As String _
                                     , ByVal strVvDelimiter As String _
                                     ) As String
    Dim intLvPreviousIndex As Integer: intLvPreviousIndex = 1
    Dim intLvIndex As Integer: intLvIndex = InStr(strVvText, strVvDelimiter) + 1
    Dim strLvTextSuffix As String: strLvTextSuffix = ""
    '   Need to delimiter to end of string if it is not already there
    strLvTextSuffix = IIf(Right$(strVvText, Len(strVvDelimiter)) = strVvDelimiter _
                        , "" _
                        , strVvDelimiter _
                        )
    strVvText = strVvText & strLvTextSuffix
    Do While intLvIndex > intLvPreviousIndex
        strVvText = Left$(strVvText, intLvIndex - 1) _
                  & Replace$(Mid$(strVvText, intLvIndex) _
                            , Mid$(strVvText _
                                  , intLvPreviousIndex _
                                  , intLvIndex - intLvPreviousIndex _
                                  ) _
                            , "" _
                            )
        '   Start of previous word
        intLvPreviousIndex = intLvIndex
        '   Start of next word
        intLvIndex = InStr(intLvIndex, strVvText, strVvDelimiter) + 1
    Loop
    '   Need to remove delimiter at end of string unless added at beginning of method
    strVvText = IIf(Right$(strVvText, Len(strLvTextSuffix)) = strLvTextSuffix _
                   , Left$(strVvText, Len(strVvText) - Len(strLvTextSuffix)) _
                   , strVvText _
                   )
    RemoveDuplicateWords = strVvText
End Function

I am sure there must be a better solution to the problem. Any takers?

Note that my solution only caters for a single word separator. Full stops, commas etc. could not be catered for without multiple calls to the function. Also the the first occurance is always the one left behind.

posted @ 8:19 PM

A piece of code I came up with whilst trying to solve a post at vbCity was what I term Combine. It basically does the opposite of Split and creates a string out of a single dimensional array.

Private Function Combine(ByVal oVvArray As Variant _
                        , ByVal strVvDelimiter As String _
                        ) As String
    Dim intLvIndex As Integer
    For intLvIndex = LBound(oVvArray) To UBound(oVvArray)
        Combine = Combine & CStr(oVvArray(intLvIndex)) & strVvDelimiter
    Next
    Combine = IIf(Right$(Combine, Len(strVvDelimiter)) = strVvDelimiter _
                 , Left$(Combine, Len(Combine) - Len(strVvDelimiter)) _
                 , Combine _
                 )
    
End Function
posted @ 8:00 PM