# Re: 给帅帅阿柳或站长等其它高手

Posted by 帅帅阿柳 on April 05, 1999 at 00:50:19:

In Reply to: 给帅帅阿柳或站长等其它高手 posted by Luben on April 05, 1999 at 00:04:16:

如果您指的是Yuan说的"mdb的compact",那么呼叫DBEngine的Compact就成了!要不然如果您要的是将字串或二进位的资料加以压缩的话,您就必须使用Compress/Uncompress的演算法,例如RLE...下例供您参考,但很明显地您就无法使用bound control来撷取资料内容了!
希望对您有些帮助

阿柳

public function compress()

On Error Resume Next

For TT = 1 To Len(Text1)
sana1 = Mid(Text1, TT, 1)
sana2 = Mid(Text1, TT + 1, 1)
sana3 = Mid(Text1, TT + 2, 1)
X = 1
If Not sana1 = sana2 Then löyty = 2

If sana1 = sana2 Then

If sana1 = sana3 Then
löyty = 1
End If

End If

If löyty = 1 Then
alku:
X = X + 1
merkki = Mid(Text1, TT + X + 1, 1)
If merkki = sana1 Then GoTo alku
sana = Chr(255) & Chr(X - 1) & sana1
TT = TT + X
End If

If löyty = 2 Then sana = sana1
Text = Text & sana
Next

Text1 = Text
end function

public function uncompress()

On Error Resume Next

For TT = 1 To Len(Text1)
sana1 = Asc(Mid(Text1, TT, 1))
sana2 = Asc(Mid(Text1, TT + 1, 1))
sana3 = Asc(Mid(Text1, TT + 2, 1))
sana4 = Asc(Mid(Text1, TT - 1, 1))

If sana1 = 255 Then

For TT6 = 1 To sana2
sana = sana & Chr(sana3)
Next

sana1 = ""
sana2 = ""
End If

If sana = "" Then

If Not sana4 = 255 Then
sana = Chr(sana1)
End If

End If

Text = Text & sana
sana = ""
Next

Text1 = Text
end function

- VB PRO NET中文资源网

Follow Ups: