扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
请参考底下做法:VB.Net 程式码如下 :Public Function URLEncode(ByRef strEnc As String) As StringDim strTmp2, strChar, strTmp, strRet As StringDim lngLoop As IntegerFor lngLoop = 0 To strEnc.Length - 1strChar = strEnc.Substring(lngLoop, 1)Select Case Asc(strChar)Case 48 To 57, 65 To 90, 97 To 122strRet = strCharCase 32strRet = "+"Case ElsestrTmp = Hex(Asc(strChar))If strTmp.Length 4 Then strTmp = strTmp.Substring(4)strRet = "%" strTmp.Substring(0, 2)If strTmp.Length 2 ThenstrTmp2 = strTmp.Substring(2)strRet = IIf(IsNumeric(strTmp.Substring(2, 1)), Chr(Val("H" strTmp2)), "%" strTmp2)End IfEnd SelectNextURLEncode = strRetEnd Function或Public Function URLenc(ByVal strEnc As String) As StringDim lngLoop, lngAsc As LongDim strChr As StringFor lngLoop = 0 To strEnc.Length - 1strChr = strEnc.Substring(lngLoop, 1)If Math.Abs(Asc(strChr)) 255 ThenURLenc = strChrElselngAsc = Asc(strChr)If lngAsc 0 Then lngAsc = lngAsc + 65536URLenc = "%" Hex((lngAsc And -256) \ 255) "%" Hex(lngAsc And 255)End IfNextEnd Function呼叫:MessageBox.Show(URLEncode("强力鎯头 PowerHammer !"))MessageBox.Show(URLenc("强力鎯头 PowerHammer !"))结果显示 :%B1j%A4O%EE%CF%C0Y+PowerHammer+%21%B1%6A%A4%4F%EE%CF%C0%59 PowerHammer ! ================================================================VB6 程式码如下 :Public Function URLEncode(strEnc As String) As StringDim strChar As String, strTmp As String, strTmp2 As String, strRet As StringDim lngLoop As LongFor lngLoop = 1 To Len(strEnc)strChar = Mid(strEnc, lngLoop, 1)Select Case Asc(strChar)Case 48 To 57, 65 To 90, 97 To 122strRet = strRet strCharCase 32strRet = strRet "+"Case ElsestrTmp = Format(Hex(Asc(strChar)), "00")strRet = strRet "%" Left(strTmp, 2)strTmp2 = Mid(strTmp, 3, 2)If Len(strTmp) 3 ThenstrRet = strRet IIf(IsNumeric(Mid(strTmp, 3, 1)), Chr(Val("H" strTmp2)), "%" strTmp2)End IfEnd SelectNextURLEncode = strRetEnd Function或Public Function URLenc(strEnc As String) As StringDim lngLoop As Long, lngAsc As LongDim strChr As StringFor lngLoop = 1 To Len(strEnc)strChr = Mid(strEnc, lngLoop, 1)If Abs(Asc(strChr)) 255 ThenURLenc = URLenc strChrElselngAsc = Asc(strChr)If lngAsc 0 Then lngAsc = lngAsc + 65536URLenc = URLenc "%" Hex((lngAsc And -256) \ 255) "%" Hex(lngAsc And 255)End IfNextEnd Function呼叫:MsgBox URLEncode("强力鎯头 PowerHammer !")MsgBox URLenc("强力鎯头 PowerHammer !")结果显示 :%B1j%A4O%EE%CF%C0Y+PowerHammer+%21%B1%6A%A4%4F%EE%CF%C0%59 PowerHammer ! ================================================================ASP 程式码如下(多此一举,因为ASP本来就有Server.URLencode) :Public Function URLEncode(strEnc)Dim strChr, intAsc, strTmp, strTmp2, strRet, lngLoopFor lngLoop = 1 To Len(strEnc)strChr = Mid(strEnc, lngLoop, 1)intAsc = Asc(strChr)If ((intAsc 58) And (intAsc 47)) Or ((intAsc 91) And (intAsc 64)) Or ((intAsc 123) And (intAsc 96)) ThenstrRet = strRet strChrElseIf intAsc = 32 ThenstrRet = strRet "+"ElsestrTmp = Hex(Asc(strChr))strRet = strRet "%" Right("00" Left(strTmp, 2), 2)strTmp2 = Mid(strTmp, 3, 2)If Len(strTmp) 3 ThenIf IsNumeric(Mid(strTmp, 3, 1)) ThenstrRet = strRet Chr(CInt("H" strTmp2))ElsestrRet = strRet "%" strTmp2End IfEnd IfEnd IfNextURLEncode = strRetEnd Function或Public Function URLenc(strEnc)Dim lngLoop, lngAsc, strChrFor lngLoop = 1 To Len(strEnc)strChr = Mid(strEnc, lngLoop, 1)If Abs(Asc(strChr)) 255 ThenURLenc = URLenc strChrElselngAsc = Asc(strChr)If lngAsc 0 Then lngAsc = lngAsc + 65536URLenc = URLenc "%" Hex((lngAsc And -256) \ 255) "%" Hex(lngAsc And 255)End IfNextEnd Function呼叫:Response.write URLEncode("强力鎯头 PowerHammer !")Response.write URLenc("强力鎯头 PowerHammer !")结果显示 :%B1j%A4O%EE%CF%C0Y+PowerHammer+%21%B1%6A%A4%4F%EE%CF%C0%59 PowerHammer !
陆港网站制作公司哪家好,找创新互联!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。创新互联自2013年创立以来到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联。
首先在窗体上添加Button1,ListBox1,下面是完整代码
Public Class Form1
Public Sub BubbleSort(ByVal arr() As Integer) '冒泡法排序
Dim temp As Double
Dim i, j As Integer
For i = 0 To arr.GetUpperBound(0) - 1
For j = i + 1 To arr.GetUpperBound(0) - 1
If arr(i) arr(j) Then
temp = arr(j)
arr(j) = arr(i)
arr(i) = temp
End If
Next
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click '调用
Dim arr() As Integer = {55, 22, 33, 11, 77, 88}
BubbleSort(arr) '调用排序过程
Me.ListBox1.Items.Clear()
For i = 0 To arr.GetUpperBound(0) - 1 '显示排序后结果
Me.ListBox1.Items.Add(arr(i).ToString)
Next
End Sub
End Class
注意:参数为动态数组;
Private Function MyF(ByRef d() As Integer)
ReDim d(4, 13) As Integer
Dim i As Integer
Dim j As Integer
Dim n As Integer
Dim MyNum(4) As Integer
For i = 1 To 4
MyNum(i) = 0
Next i
Randomize
For i = 1 To 4
For j = 1 To 13
n = Int(Rnd * 4 + 1)
Do While MyNum(n) = 13
n = Int(Rnd * 4 + 1)
Loop
d(i, j) = n
MyNum(n) = MyNum(n) + 1
Next j
Next i
End Function
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流