Attribute VB_Name = "hlp_CharLength"
' Modul for Visual Basic 6
' Copyright (C) 2003-2007 Jan Vorel
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.

' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

' This is a shared modul, class modul, usercontrol or form. It is also
' published under the GNU General Public License.

' If you have any questions, suggestions or bug reports about this product,
' contact me: info@ctuser.net; Do not contact me about general B.A.S.I.C.
' language or A.P.I. issues

Private Declare Sub RtlMoveMemory Lib "kernel32" (lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)

Option Explicit
Option Base 0

'#CharLength_FlagA
' 1 = No LenLongToChar
' 2 = No LenCharToLong

Public Function LenLongToChar(ByVal xLong1 As Long) As String
  LenLongToChar = String(4&, vbNullChar)
  Call RtlMoveMemory(ByVal LenLongToChar, ByVal VarPtr(xLong1), 4&)
  End Function

Public Function LenCharToLong(ByVal xChar1 As String, Optional ByVal Address As Long = 1&) As Long
  xChar1 = Mid(xChar1, Address, 4&) & String(4&, vbNullChar)
  Call RtlMoveMemory(ByVal VarPtr(LenCharToLong), ByVal xChar1, 4&)
  End Function

