MKI, CVI y tal...
Funciones numéricas de conversión

 

Fecha: 04/Feb/99 (21/Sep/97 -No, no hay error en la fecha)
Autor: Joe LeVasseur < [email protected] >


SUPER NOTA: Estas funciones me la envió el colega Joe en la fecha indicada arriba, pero por un despiste (más grande de los que acostumbro a tener), se me olvidó publicarlo... lo siento, pero más vale tarde que nunca...

From: "Joe LeVasseur" <[email protected]>
To: "Guillermo" <[email protected]>
Subject: MKI, CVI y tal...
Date sent: Sun, 21 Sep 1997 01:48:51 -0400

Billy-
Los puedo hacer las versiones MBF
si hace falta.
Cada semana alguien pide estos
functions, y VB32 no los tiene.
Joe


El código:

'
Option Explicit
' Old Basic routines, unsupported in Win/VB3/4/5
' uses RtlMoveMemory to replace hMemCpy-
' since hMemCpy is not exported in Win32.
' Adapted from article in KB
' Joe LeVasseur <[email protected]>
'////////////////////////////////////////////////
Declare Sub hMemCpy Lib "KERNEL32" Alias "RtlMoveMemory" _
   (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)

Function MKI(x As Integer) As String
   Dim szTemp     As String
   szTemp = Space$(2)
   hMemCpy ByVal szTemp, x, 2
   MKI = szTemp
End Function

Function CVI(x As String) As Integer
   Dim iTemp     As Integer
   If Len(x) <> 2 Then
      MsgBox "Illegal Function Call"
      Exit Function
   End If
   hMemCpy iTemp, ByVal x, 2
   CVI = iTemp
End Function

Function MKL(x As Long) As String
   Dim szTemp     As String
   szTemp = Space$(4)
   hMemCpy ByVal szTemp, x, 4
   MKL = szTemp
End Function

Function CVL(x As String) As Long
   Dim lTemp      As Long
   If Len(x) <> 4 Then
      MsgBox "Illegal Function Call"
      Exit Function
   End If
   hMemCpy lTemp, ByVal x, 4
   CVL = lTemp
End Function

Function MKS(x As Single) As String
   Dim szTemp     As String
   szTemp = Space$(4)
   hMemCpy ByVal szTemp, x, 4
   MKS = szTemp
End Function

Function CVS(x As String) As Single
   Dim sTemp      As Single
   If Len(x) <> 4 Then
      MsgBox "Illegal Function Call"
      Exit Function
   End If
   hMemCpy sTemp, ByVal x, 4
   CVS = sTemp
End Function

Function MKD(x As Double) As String
   Dim szTemp      As String
   szTemp = Space$(8)
   hMemCpy ByVal szTemp, x, 8
   MKD = szTemp
End Function

Function CVD(x As String) As Double
   Dim dTemp      As Double
   If Len(x) <> 8 Then
      MsgBox "Illegal Function Call"
      Exit Function
   End If
   hMemCpy dTemp, ByVal x, 8
   CVD = dTemp
End Function

 


ir al índice