Thread: I'm stuck
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default I'm stuck

What does "StrSort" do?

Barb Reinhardt




"Magius96" wrote:

I can't figure out what's wrong with this function. When I try to call it
from Excel it gives me the "#VALUE!" error.

This function should be an implementation of the Burrows-Wheeler
Transformation. I have gone through the code with a fine tooth comb, but
can't find the problem myself.

### START CODE ###

Public Function BWT_Encode(CodeString) As String
Dim TheStrings() As String
Dim Result As String
Dim Length As Long
Dim A As Long

Length = Len(CodeString)
Result = ""

' First build the string table
TheStrings(1) = CodeString
For A = 2 To Length
TheStrings(A) = Right(TheStrings(A - 1), 1) & Left(TheStrings(A - 1),
Length - 1)
Next A

' Now sort the array alphabetically
Call StrSort(TheStrings(), True, True)

' Now get last letter
For A = 1 To Length
Result = Result & Right(TheStrings(A), 1)
Next A
BWT_Encode = Result
End Function

### END CODE ###