Novell Home

Talk:Nwaddin

From Developer Community

This doesn't report volume sizes over a terabyte - it returns an error to the spreadsheet. Any tweaks I can make?

TB Volume sizes

For volume sizes in the TB range, the VBA "long" can no longer cope.

You can work around some of the limitations by altering the definitions as follows:

Public Function NWVolSize(ByVal Server As String, ByVal Volume As String) As Currency

Public Function NWVolSpaceAvail(ByVal Server As String, ByVal Volume As String) As Currency

Public Function NWVolSpacePurgeable(ByVal Server As String, ByVal Volume As String) As Currency

Hope this helps.

Regards, Thomas



2008-01-09: One Solution is to create a temporary result with double precision.

Example (Changes in bold):

   ' ====================================================
   ' Function: NWVolSize
   '
   ' Input     Server Name
   '           Volume Name
   ' Returns   Size of volume in MB
   ' On error  Returns NULL
   ' ====================================================
   
   Public Function NWVolSize(ByVal Server As String, ByVal Volume As String) As Long
       
   Dim lhConn As Long
   Dim lRet As Long
   Dim DSI As DIR_SPACE_INFO
   Dim iVol As Integer
   Dim Result As Double
  
   lhConn = OpenConnByName(Server)
   If lhConn <> 0 Then
       lRet = NWGetVolumeNumber(lhConn, UCase$(Volume) & vbNullChar, iVol)
       If lRet = ERR_SUCCESS Then
           lRet = NWGetDirSpaceInfo(lhConn, 0, iVol, DSI)
               If lRet = ERR_SUCCESS Then
                   Result = (CDbl(DSI.totalBlocks) * CDbl(DSI.sectorsPerBlock) / 2) / 1024
                   NWVolSize = CLng(Result)
               Else
                   NWVolSize = Null
               End If
       Else
           NWVolSize = Null
       End If
       Call NWCCCloseConn(lhConn)
   Else
       NWVolSize = Null
   End If
   
   End Function

Regards, Rolf

Novell® Making IT Work As One

© 2009 Novell, Inc. All Rights Reserved.