热情软件屋

 

在VB中如何实现URLEncode()


编号:QA002883
建立日期: 2000年4月25日 最后修改日期:2000年4月25日
所属类别:

文章:

    李海译自《VBxtras' VBHowTo Issue #40》
    是否需要编码文本或其他URL,这样可以在传递给另一个URL作为参数,但是文本中可能包括那些在URL中有特殊意义的字符?在ASP中,你可以使用Server.URLEncode(),但是在VB中如何做?下面是一个函数:
     Public Function URLEncode(strInput As String) As String
     Dim strOutput As String
     Dim intAscii As Integer
     Dim i As Integer
    
    
     For i = 1 To Len(strInput)
     intAscii = Asc(Mid(strInput, i, 1))
     If ((intAscii < 58) And (intAscii > 47)) Or _
     ((intAscii < 91) And (intAscii > 64)) Or _
     ((intAscii < 123) And (intAscii > 96)) Then
     strOutput = strOutput & Chr$(intAscii)
     Else
     strOutput = strOutput & _
     IIf(intAscii < 16, "%0", "%") & _
     Trim$(Hex$(intAscii))
     End If
     Next
     URLEncode = strOutput
     End Function

文章来源:VBxtras

 
把这个问题推荐给朋友
   
   
您的意见类别
您的名字
您的电子邮件
您的建议(请尽可能详细)
 
 

版权所有 1997-2008 热情软件屋
如果您有任何建议和意见, 请给我发个电子邮件 askpro@china-askpro.com
Web Designed by ZebraStudio