|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
类模块,UCode。GetURL 是原函数, URLEncode是同等功能,速度更快的,新函数。调用函数名改一下就行,或者直接删除原函数,改新函数为就函数名,即可。
- Function GetURL$(txt$, Optional LC = &H804) 'Chn &H804/Taiwan &H404/Japan &H411/ Korea &H412
- Dim a() As Byte: a = StrConv(txt, vbFromUnicode, LC)
- For i = 0 To UBound(a)
- GetURL = GetURL & "%" & Right("0" & Hex(a(i)), 2)
- 'DoEvents
- 'UserForm1.Caption = Application.Text((i / UBound(a)), "0.00%") '倒计时模块 ,耗时比较大
- Next
- End Function
- Public Function URLEncode( _
- StringVal As String, _
- Optional SpaceAsPlus As Boolean = False _
- ) As String
- Dim StringLen As Long: StringLen = Len(StringVal)
- If StringLen > 0 Then
- ReDim result(StringLen) As String
- Dim i As Long, CharCode As Integer
- Dim Char As String, Space As String
- If SpaceAsPlus Then Space = "+" Else Space = "%20"
- For i = 1 To StringLen
- Char = Mid$(StringVal, i, 1)
- CharCode = Asc(Char)
- Select Case CharCode
- Case 97 To 122, 65 To 90, 48 To 57, 45, 46, 95, 126
- result(i) = Char
- Case 32
- result(i) = Space
- Case 0 To 15
- result(i) = "%0" & Hex(CharCode)
- Case Else
- result(i) = "%" & Hex(CharCode)
- End Select
- Next i
- URLEncode = Join(result, "")
- End If
- End Function
复制代码 |
|