close
在舊有的 String 在處理大量文字時,速度會很慢,尤其是在 刪除 取代 做 大量 文字處理時,是一件很費時的工作
StringBuilder 是一個很強大的工具,協助在處理 大量 的文字
隸屬 System.Text
常見用法
Dim StrBuilder As StringBuilder = New StringBuilder
StrBuilder.Append("text") '加入文字
StrBuilder.Append("Start Record time," + Now.ToString("yyyy/MM/dd HH:mm") + vbCrLf) '新增文字 且加入換行
StrBuilder.AppendLine '換行符號
StrBuilder.remove(x,i) '由編號 x 開始移除 i 個
StrBuilder.Insert( x,str,times) '在編號 X 前 插入文字 str , optional times 要重複插入的次數 內定 1次
StrBuilder.replace("str", "Newstr") '將舊有文字 str 改成 Newstr
StrBuilder.tostring
http://www.dotblogs.com.tw/puma/archive/2008/05/31/4188.aspx
全站熱搜