|
|
|
Click here to copy the following block |
Function RLE_Compress(TString As String) As String Dim TChar1, TChar2, TChar3, TChar4, StrBuff, StrBuffer As String Dim RLE As Boolean Dim XPos As Integer Dim TLoop As Integer For TLoop = 1 To Len(TString) TChar1 = Mid(TString, TLoop, 1) TChar2 = Mid(TString, TLoop + 1, 1) TChar3 = Mid(TString, TLoop + 2, 1) XPos = 1 If Not TChar1 = TChar2 Then RLE = False If TChar1 = TChar2 And TChar1 = TChar3 Then RLE = True End If If RLE = True Then DoLoop: XPos = XPos + 1 TChar4 = Mid(TString, TLoop + XPos, 1) If TChar4 = TChar1 Then GoTo DoLoop StrBuff = Chr(255) & Chr(XPos - 1) & TChar1 TLoop = TLoop + XPos End If If RLE = False Then StrBuff = TChar1 StrBuffer = StrBuffer & StrBuff Next RLE_Compress = StrBuffer End Function Function RLE_UNCompress(TString As String) As String Dim TChar1, TChar2, TChar3, TChar4 As Integer Dim StrBuff, StrBuffer As String On Error Resume Next Dim XPos As Integer Dim TLoop As Integer For TLoop = 1 To Len(TString) TChar1 = Asc(Mid(TString, TLoop, 1)) TChar2 = Asc(Mid(TString, TLoop + 1, 1)) TChar3 = Asc(Mid(TString, TLoop + 2, 1)) TChar4 = Asc(Mid(TString, TLoop - 1, 1)) If TChar1 = 255 Then For XPos = 1 To TChar2 StrBuff = StrBuff & Chr(TChar3) Next TChar1 = "" TChar2 = "" End If If StrBuff = "" Then If Not TChar4 = 255 Then StrBuff = Chr(TChar1) End If End If StrBuffer = StrBuffer & StrBuff StrBuff = "" Next RLE_UNCompress = StrBuffer End Function |
Click here to copy the following block | Private Sub Command1_Click() Text1.Text = RLE_Compress(Text1.Text) End Sub
Private Sub Command2_Click() Text1.Text = RLE_UNCompress(Text1.Text)
End Sub
Private Sub Form_Load() Text1.Text = "aaaaaaaaaaaabbbbbbbbbbbccccccccccyyyyyyyyyyy" Command1.Caption = "Compress" Command2.Caption = "UnCompress" End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|