home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / DXFWriter_20312811162006.psc / DXFWriter / cAddString.cls < prev    next >
Text File  |  2006-11-16  |  3KB  |  97 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "cAddString"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = False
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. '----------------------------------------------------------
  15. '     ⌐ 2006, Athanasios Gardos
  16. 'e-mail: gardos@hol.gr
  17. 'You may freely use, modify and distribute this source code
  18. '
  19. 'Last update: November 16, 2006
  20. 'Please visit:
  21. '     http://business.hol.gr/gardos/
  22. ' or
  23. '     http://avax.invisionzone.com/
  24. 'for development tools and more source code
  25. '-----------------------------------------------------------
  26.  
  27. Option Explicit
  28.  
  29. Dim m_Dim As Long
  30. Dim m_MaxBytes As Long
  31. Dim m_Buffer() As Byte
  32. Dim m_pointer As Long
  33.  
  34. Public Property Let MaxBytes(ByVal v As Long)
  35.     If v <= 0 Then Exit Property
  36.     m_MaxBytes = v
  37.     m_Dim = 2 * MaxBytes - 1
  38.     ReDim m_Buffer(m_Dim) As Byte
  39. End Property
  40.  
  41. Public Property Get MaxBytes() As Long
  42.     MaxBytes = m_MaxBytes
  43. End Property
  44.  
  45. Function BeginAdd() As Boolean
  46.     m_pointer = 0
  47.     BeginAdd = True
  48. End Function
  49.  
  50. Public Function Length() As Long
  51.     Length = m_pointer / 2
  52. End Function
  53.  
  54. Function AddString(sString As String) As Boolean
  55.     Dim llen As Long
  56.     llen = LenB(sString)
  57.     If m_pointer + llen < m_Dim Then
  58.        If llen <> 0 Then
  59.           Call CopyMemory(ByVal VarPtr(m_Buffer(m_pointer)), ByVal StrPtr(sString), llen)
  60.           m_pointer = m_pointer + llen
  61.        End If
  62.        AddString = True
  63.     Else
  64.        m_Dim = m_Dim * 2
  65.        ReDim Preserve m_Buffer(m_Dim) As Byte
  66.        AddString = AddString(sString)
  67.     End If
  68. End Function
  69.  
  70. Function Add2Strings(sString1 As String, sString2 As String) As Boolean
  71.     If AddString(sString1) = False Then Exit Function
  72.     Add2Strings = AddString(sString2)
  73. End Function
  74.  
  75. Function CurString() As String
  76.     If m_pointer = 0 Then Exit Function
  77.     CurString = Space$(m_pointer / 2)
  78.     Call CopyMemory(ByVal StrPtr(CurString), ByVal VarPtr(m_Buffer(0)), m_pointer)
  79. End Function
  80.  
  81. Function EndAdd() As String
  82.     If m_pointer = 0 Then Exit Function
  83.     EndAdd = Space$(m_pointer / 2)
  84.     Call CopyMemory(ByVal StrPtr(EndAdd), ByVal VarPtr(m_Buffer(0)), m_pointer)
  85.     Call BeginAdd
  86. End Function
  87.  
  88. Private Sub Class_Initialize()
  89.     m_pointer = 0
  90.     MaxBytes = 128000
  91. End Sub
  92.  
  93. Private Sub Class_Terminate()
  94.     m_pointer = 0
  95.     Erase m_Buffer
  96. End Sub
  97.