首页/技术开发/内容

压缩HTMl文件

技术开发2024-06-14 阅读()
*.htm;*.html"
Command1.Caption = "打开"
Command2.Caption = "保存"
End Sub

Private Sub Command1_Click()
On Error Resume Next
Dim TextLine As String
CommonDialog1.ShowOpen
If Err <> 32755 Then
  Text1 = ""
'打开文件
  Open CommonDialog1.filename For Input As #1
Do While Not EOF(1)
  Line Input #1, TextLine
'去掉左边和右边的空格,再换行
Text1 = Text1 & Trim(TextLine) & vbCrLf
'若上面这句换成:
'  Text1 = Text1 & Trim(TextLine)
'即去掉空格但不换行,这样,压缩率更大,但是它的可读性就差多了
   Loop Close #1
End If
End Sub

Private Sub Command2_Click()
On Error Resume Next
CommonDialog1.ShowSave
If Err <> 32755 Then
'保存文件
    Open CommonDialog1.filename For Output As #1
    Print #1, Text1
    Close #1
  End If
End Sub

第1页  第2页 

……

相关阅读