| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 513 人关注过本帖
标题:帮忙解释这段代码
只看楼主 加入收藏
vip99
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-8-31
收藏
 问题点数:0 回复次数:1 
帮忙解释这段代码
Private Sub Command1_Click()
Text1.Text = UnEnscape(Text2.Text)
End Sub

Private Sub Command2_Click()
Text2.Text = Enscape(Text1.Text)

End Sub

Private Sub Form_Load()
Command1.Enabled = False
Command2.Enabled = False

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = RGB(255, 255, 255)

End Sub

Private Sub Label3_Click()
MsgBox "版权所有:黑蚂蚁" + vbCrLf + "2008-9-12 17:22", vbOKOnly, "关于"
End Sub


Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = RGB(100, 200, 20)
End Sub

Private Sub Label3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = RGB(255, 255, 255)

End Sub

Private Sub Text1_Change()
Command1.Enabled = False
Command2.Enabled = True

End Sub


Private Sub Text2_Change()
Command1.Enabled = True
Command2.Enabled = False
End Sub
Function ChangeToChar(CharAsc As Long)
On Error GoTo OnError
       ChangeToChar = ChrW(CharAsc)
       Exit Function
OnError:
       Exit Function
End Function
Function UnEnscape(enstr As String) As String
Dim DataLen As Long
Dim TempData As String
Dim filepoint As Long
Dim ChinaText As Long
DataLen = Len(enstr)
filepoint = 1
Do While (filepoint <= DataLen)
    If Mid(enstr, filepoint, 1) = "%" Then
       If Mid(enstr, filepoint + 1, 1) = "u" Then
       On Error Resume Next
       ChinaText = CLng("&H" + Mid(enstr, filepoint + 2, 4))
       TempData = TempData + ChangeToChar(ChinaText)
       filepoint = filepoint + 6
       Else
       TempData = TempData + ChrW(CLng("&H" + Mid(enstr, filepoint + 1, 2)))
       filepoint = filepoint + 3
       End If
     Else
       TempData = TempData + Mid(enstr, filepoint, 1)
       filepoint = filepoint + 1
    End If
Loop
UnEnscape = TempData
End Function

Function Enscape(enstr As String) As String
Dim OutPutStr As String
Dim TmpStr As String
Dim DataLen As Long
TmpStr = ""
DataLen = Len(enstr)
Dim TempNum As Long
For i = 1 To DataLen
TempNum = AscW(Mid(enstr, i, 1))
   Debug.Print TempNum
   If TempNum < 16 And TempNum > 0 Then
      TmpStr = TmpStr + "%0" + Hex(TempNum)
   
   ElseIf 48 <= TempNum And TempNum <= 57 Then
      
      TmpStr = TmpStr + Mid(enstr, i, 1)
      
    ElseIf 65 <= TempNum And TempNum <= 90 Then
      
      TmpStr = TmpStr + Mid(enstr, i, 1)
      
    ElseIf 97 <= TempNum And TempNum <= 122 Then
      
      TmpStr = TmpStr + Mid(enstr, i, 1)
      
   
    ElseIf 16 <= TempNum And TempNum < 256 Then
      TmpStr = TmpStr + "%" + Hex(TempNum)
 
    ElseIf 4096 > TempNum And TempNum >= 256 Then
            If TempNum > 0 Then
      TmpStr = TmpStr + "%u0" + Hex(TempNum)
      Else
      TmpStr = TmpStr + "%u0" + Hex(CLng(&H10000) + TempNum)
      End If
    ElseIf Abs(TempNum) >= 4096 Then
      If TempNum > 0 Then
      TmpStr = TmpStr + "%u" + Hex(TempNum)
      Else
      TmpStr = TmpStr + "%u" + Hex(CLng(&H10000) + TempNum)
      End If
      
    End If

Next
Enscape = TmpStr
End Function


这个是HTML  16进制加码解码谁帮我把每句代码意思给我解释下
搜索更多相关主题的帖子: 代码 解释 
2008-09-12 14:11
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
收藏
得分:0 
url_decode
2008-09-12 14:27
快速回复:帮忙解释这段代码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015942 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved