copymemory函数

yuzzw 2003-08-29 03:49:53
请教高手怎么构造一很大的string,可以往里面塞字符串,而不是重新构造的???就好象java中的stringbuff类

用copymemory函数的话怎么做呢???
...全文
91 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bbgbianbaogui 2003-08-29
  • 打赏
  • 举报
回复
Dim str1 As String
Private Sub Command1_Click()
str1 = str1 & "122324klfdjlfj"
End Sub

Private Sub Command2_Click()
Print str1
End Sub
这样的str1不也是很大吗?
射天狼 2003-08-29
  • 打赏
  • 举报
回复
字符串有两种:变长与定长的字符串。

穇变长字符串最多可包含大约 20 亿 ( 2^31)个字符。
穇定长字符串可包含 1 到大约 64K ( 2^16 ) 个字符。

注意 Public 定长字符串不能在类模块中使用。

String 之字符码的范围是 0 到 255。字符集的前 128 个字符(0 到 127)对应于标准的 U.S. 键盘上的字符与符号。这前 128 个字符与 ASCII 字符集中所定义的相同后 128 个字符(128 到 255)则代表特殊字符,例如国际字符,重音符号,货币符号及分数。String 的类型声明字符为美圆号 ($)。
hisofty 2003-08-29
  • 打赏
  • 举报
回复
'Example Name:CopyMemory
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim sSave As String, Cnt As Long, T As Long, Pos As Long, Length As Long
Const mStr = "Hello "
Length = Len(mStr)
sSave = Space(5000 * Length) 'make buffer for justified comparison
'Get the current tickcount
T = GetTickCount
Pos = 1
sSave = Space(5000 * Length)
For Cnt = 1 To 5000
Mid(sSave, Pos, Length) = mStr
Pos = Pos + Length
Next Cnt
'Show the results
MsgBox "It took Visual basic" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
'Get the current tickcount
T = GetTickCount
Pos = 0
sSave = Space(5000 * Length)
For Cnt = 1 To 5000
CopyMemory ByVal StrPtr(sSave) + Pos, ByVal StrPtr(mStr), LenB(mStr)
Pos = Pos + LenB(mStr)
Next Cnt
'Show the results
MsgBox "It took CopyMemory" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
End Sub
射天狼 2003-08-29
  • 打赏
  • 举报
回复
dim s as String
dim i as long

for i = 1 to 10000
s = s & cstr(i)
next

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧