Public Function Corp_Name()    Dim DogAddr As Long        ' The address read
    Dim DogBytes As Long       ' The number of bytes read
    Dim DogDataStr As String      ' The data read
    Dim DogDataInt As Long
    Dim DogDataDouble As Double
    Dim Ret As Long            ' The return value
    
    DogAddr = 20
    DogBytes = 30
    DogDataStr = "                              "
    Ret = DogRead_Str(DogBytes, DogAddr, DogDataStr)
    
    Corp_Name = Trim(DogDataStr)
    
End Function我在模块中声明了如上一个函数.还能不能在模块中再定义一个APP_CorpName变量,并赋值呢?

解决方案 »

  1.   

    对,在模块中定义一个全局变量APP_CorpName,并且赋值为Corp_Name函数的返回值
      

  2.   

    Dim APP_CorpNamePublic Function Corp_Name()    Dim DogAddr As Long        ' The address read
        Dim DogBytes As Long      ' The number of bytes read
        Dim DogDataStr As String      ' The data read
        Dim DogDataInt As Long
        Dim DogDataDouble As Double
        Dim Ret As Long            ' The return value
        
        DogAddr = 20
        DogBytes = 30
        DogDataStr = "                              "
        Ret = DogRead_Str(DogBytes, DogAddr, DogDataStr)
        
        Corp_Name = Trim(DogDataStr)
        
    End FunctionPrivate Sub Form_Load()
    APP_CorpName = Corp_Name
    End Sub
      

  3.   


    dim APP_CorpName
    Public Function Corp_Name() as string    Dim DogAddr As Long        ' The address read 
        Dim DogBytes As Long      ' The number of bytes read 
        Dim DogDataStr As String      ' The data read 
        Dim DogDataInt As Long 
        Dim DogDataDouble As Double 
        Dim Ret As Long            ' The return value 
        
        DogAddr = 20 
        DogBytes = 30 
        DogDataStr = "                              " 
        Ret = DogRead_Str(DogBytes, DogAddr, DogDataStr) 
        
        Corp_Name = Trim(DogDataStr) 
        APP_CorpName=Corp_Name
    End Function
    你原来的函数的返回值是变型的,不推荐这么使用
      

  4.   

    在函数内部定义的不是全局变量。SYSSZ的代码已很清楚了。
      

  5.   

    public APP_CorpName as long
      

  6.   

    Global APP_CorpName as string