www.pudn.com > URLEncoding.rar > Form1.frm


VERSION 5.00 
Begin VB.Form Form1  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "Form1" 
   ClientHeight    =   1605 
   ClientLeft      =   45 
   ClientTop       =   435 
   ClientWidth     =   3645 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   1605 
   ScaleWidth      =   3645 
   StartUpPosition =   3  'Windows Default 
   Begin VB.TextBox txt2  
      Height          =   1335 
      Left            =   0 
      MultiLine       =   -1  'True 
      TabIndex        =   1 
      Top             =   240 
      Width           =   3615 
   End 
   Begin VB.TextBox txt1  
      Height          =   285 
      Left            =   0 
      TabIndex        =   0 
      Top             =   0 
      Width           =   3615 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
 
Private Sub txt1_Change() 
    Dim i As Long 
    txt2 = "" 
    For i = 1 To Len(txt1) 
        txt2 = txt2 & IIf(Mid(txt1, i, 1) <> "=" And Mid(txt1, i, 1) <> "?", "%" & DEC_to_HEX(Asc(Mid(txt1, i, 1))), Mid(txt1, i, 1)) 
    Next 
End Sub 
 
' 用途:将十进制转化为十六进制 
' 输入:Dec(十进制数) 
' 输入数据类型:Long 
' 输出:DEC_to_HEX(十六进制数) 
' 输出数据类型:String 
' 输入的最大数为2147483647,输出最大数为7FFFFFFF 
Public Function DEC_to_HEX(Dec As Long) As String 
    Dim a As String 
    DEC_to_HEX = "" 
    Do While Dec > 0 
        a = CStr(Dec Mod 16) 
        Select Case a 
            Case "10": a = "A" 
            Case "11": a = "B" 
            Case "12": a = "C" 
            Case "13": a = "D" 
            Case "14": a = "E" 
            Case "15": a = "F" 
        End Select 
        DEC_to_HEX = a & DEC_to_HEX 
        Dec = Dec \ 16 
    Loop 
End Function