复制代码 代码如下:
Private Declare Function GetTickCount Lib "kernel32" () As Int32
Private Function TestByRef(ByRef aa As String) As String
aa = "1" & aa
TestByRef = aa
End Function
Private Function TestByVal(ByVal aa As String) As String
aa = "1" & aa
TestByVal = aa
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim teststr As String
Dim Newstr As String
Dim t As Int32
Dim II As Int32
teststr = "wosdfsdfdsfdsfsfdsfsfsfsfsfsfdsfdsfcvxcvxcvcxvvcxvvvxvcvxv"
t = GetTickCount
For II = 1 To 10000
Newstr = TestByRef(teststr)
Next
MsgBox("ByRef " & CStr(GetTickCount - t))
t = GetTickCount
For II = 1 To 10000
Newstr = TestByVal(teststr)
Next
MsgBox("ByVal " & CStr(GetTickCount - t))
End Sub
新闻热点
疑难解答
图片精选