?? 如何以一個模板為基礎生成文件.txt
字號:
你 現 在 訪 問 的 站 點 的 頁 面 實 際 上 就 是 采 用 模 板 方 式 生 成 的 。 你 可 以 這 樣 組 織 你 的 模 板 文 件 :
<HTML>
...
<B><!-- Name --></B>
...
</HTML>
然 后 使 用 Replace函 數 將 “ <!-- Name -->” 替 換 為 其 他 的 值 :
Open "template.htm" For Input As #1
Open "result.htm" For Output As #2
Do While Not Eof(1)
Line Input #1, s
s = Replace(s, , "<!-- Name -->", rd("Name"))
Print #2, s
Loop
Close 1
Close 2
Replace是 VB 6的 新 函 數 , 如 果 你 使 用 的 是 vb6, 可 以 加 入 下 面 的 函 數 :
Public Function Replace(sIn As String, sFind As String, _
sReplace As String, Optional nStart As Long = 1, _
Optional nCount As Long = -1, Optional bCompare As _
VbCompareMethod = vbBinaryCompare) As String
Dim nC As Long, nPos As Integer, sOut As String
sOut = sIn
nPos = InStr(nStart, sOut, sFind, bCompare)
If nPos = 0 Then GoTo EndFn:
Do
nC = nC + 1
sOut = Left(sOut, nPos - 1) & sReplace & _
Mid(sOut, nPos + Len(sFind))
If nCount <> -1 And nC >= nCount Then Exit Do
nPos = InStr(nStart, sOut, sFind, bCompare)
Loop While nPos > 0
EndFn:
Replace = sOut
End Function
<END>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -