查看: 62  |  回复: 0
VB6 字符串和Byte数组相互转换,可以直接arrA = strA和strA = arrA
楼主
发表于 3月14日 08:56

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Sub Command1_Click()
    Const lngMax As Long = 100000000
    Dim arrA() As Byte
    ReDim arrA(lngMax)
    Dim strA As String
    Dim strB As String

    Dim lngTickStartTime As Long
    Dim lngTickEndTime As Long
    
    strA = String(lngMax, 65)
    
    lngTickStartTime = GetTickCount    '获取开始时间 ----------------需要计算时间的代码 V----------------
    arrA = strA
    lngTickEndTime = GetTickCount      '获取结束时间 ----------------需要计算时间的代码 A----------------

    '将时间差值输出
    Dim strShow As String
    strShow = f_TimeStampToStr(lngTickEndTime - lngTickStartTime, 0)
    Debug.Print arrA(8) & "  " & strShow
    
    lngTickStartTime = GetTickCount    '获取开始时间 ----------------需要计算时间的代码 V----------------
    strB = arrA
    lngTickEndTime = GetTickCount      '获取结束时间 ----------------需要计算时间的代码 A----------------

    '将时间差值输出
    strShow = f_TimeStampToStr(lngTickEndTime - lngTickStartTime, 0)
    Debug.Print Left(strB, 3) & "  " & strShow
End Sub

运行结果:

65  234毫秒
AAA  344毫秒

所以得出结论:

arrA = strA和strA = arrA

关于时间请参考《VB6 利用API获得时间戳精确到毫秒并计算开始和结束时间的差到天日时分秒毫秒,子函数 f_TimeStampToStr》,地址:http://manongku.com/p1772306.html 

您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com