zoukankan      html  css  js  c++  java
  • VB API判断数组为空

    1.

    'API判断数组为空或没有初始化

    Private Declare Function SafeArrayGetDim Lib "oleaut32.dll" (ByRef saArray() As Any) As Long  

    Private Sub Command1_Click()
    Dim tmp() As String
    If SafeArrayGetDim(tmp) = 0 Then
    MsgBox "数组为空或没有初始化"
    End If
    End Sub

    2.

    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (

                                                                                  Destination As Any, Source As Any, ByVal Length As Long)
    Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Var() As Any) As Long

    Private Sub Form_Load()
        Dim S() As Long                                            //动态数组
        Dim VarPtrArrayAddress As Long                 //对数组用函数VarPtrArray得到的地址
        Dim SafeArrayPoint As Long                         //'SafeArray结构的指针的值
        
        VarPtrArrayAddress = VarPtrArray(S)

        CopyMemory SafeArrayPoint, ByVal VarPtrArrayAddress, 4   //没有分配内存,这时候SafeArrayPoint的值为0
        If SafeArrayPoint = 0 Then
            MsgBox "空"
        End If

    End Sub

  • 相关阅读:
    Java并发之线程管理(线程基础知识)
    spring aop使用
    java动态代理
    java深拷贝与浅拷贝
    装饰模式(也叫包装模式)
    Spring基于XML方式的使用
    javaWeb域对象
    静态代理和动态代理
    getAnnotation的一个坑
    (转)文件上传org.apache.tomcat.util.http.fileupload.FileUploadException: Stream closed
  • 原文地址:https://www.cnblogs.com/rosesmall/p/6398115.html
Copyright © 2011-2022 走看看