前两天,忽然对字符串与ascii转化有了兴趣,特地编写了以下代码,可以实现字符串与ASCII码的转化,很简单的~~代码贴在下面了。
由此做了一个“ 传音墙”的页面:http://www.taoyoyo.net/clab/pass/StrToAscW.asp
你可以把对朋友想说的话,写在页面中,然后把生成的地址,发送给你的朋友!
都来试试看吧~~
试验祝福网页:http://www.taoyoyo.net/clab/pass/StrToAsc_1.asp
ASP代码:
<%^------字符串转化为ASCIIFunction StrToAsc(pStr, pSymbol)Dim pAscDim ipAsc = ""^逐字符转化ASCIIFor i = 1 To Len(pStr & "")pAsc = pAsc & Asc(Mid(pStr, i, 1)) & pSymbol^if pDebug="1" then response.write(i & "|" & pAsc & "<br />")NextStrToAsc = pAscif pDebug="1" then response.write("=========" & "|" & StrToAsc & "<br />")End Function^------ASCII转化为字符串Function AscToStr(pAsc, pSymbol)Dim i, jDim pStrDim pTxtpStr = ""j = 0For i = 1 To Len(pAsc)If Mid(pAsc, i, 1) = pSymbol Then^分隔取得每段ASCII码pTxt = Mid(pAsc, j + 1, i - 1 - j)^转化每段ASCII码pStr = pStr & Chr(pTxt)j = iEnd IfNextAscToStr = pStrEnd Function%>
VB代码:
Function StrToAsc(pStr, pSymbol As String)Dim pAsc As StringDim i As IntegerpAsc = ""For i = 1 To Len(pStr & "")pAsc = pAsc & Asc(Mid(pStr, i, 1)) & pSymbolNextStrToAsc = pAscEnd FunctionFunction AscToStr(pAsc, pSymbol As String)Dim i, j As IntegerDim pStr As StringDim pTxt As StringpStr = ""j = 0For i = 1 To Len(pAsc)If Mid(pAsc, i, 1) = pSymbol ThenpTxt = Mid(pAsc, j + 1, i - 1 - j)pStr = pStr & Chr(pTxt)j = iEnd IfNextAscToStr = pStrEnd Function
【版權聲明】
本文爲原創,遵循CC 4.0 BY-SA版權協議!轉載時請附上原文鏈接及本聲明。
原文鏈接:https://tdlib.com/am.php?t=nNNv80ksfYNJ Tag: VB技巧 ASP知识 网页编程 TTTBLOG