Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

MK? And CV? - Convert numbers to strings and back
[ All Languages » VB »  Math]

Total Hit ( 3057)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' This group of routines convert a numeric value into a string
' that contain the internal representation of the number.
' They can be useful when converting outdated QuickBasic programs,
' because that language supported these functions that were
' never ported to Visual Basic.

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
  Any, source As Any, ByVal numBytes As Long)

' Convert from Integer to String

Function MKI(value As Integer) As String
  MKI = Space$(2)
  CopyMemory ByVal MKI, value, 2
End Function

' Convert from String to Integer

Function CVI(arg As String) As Integer
  If Len(arg) < 2 Then Err.Raise 13
  CopyMemory CVI, ByVal arg, 2
End Function

' Convert from Long to String

Function MKL(value As Long) As String
  MKL = Space$(4)
  CopyMemory ByVal MKL, value, 4
End Function

' Convert from String to Long

Function CVL(arg As String) As Long
  If Len(arg) < 4 Then Err.Raise 13
  CopyMemory CVL, ByVal arg, 4
End Function

' Convert from Single to String

Function MKS(value As Single) As String
  MKS = Space$(4)
  CopyMemory ByVal MKS, value, 4
End Function

' Convert from String to Single

Function CVS(arg As String) As Single
  If Len(arg) < 4 Then Err.Raise 13
  CopyMemory CVS, ByVal arg, 4
End Function

' Convert from Double to String

Function MKD(value As Double) As String
  MKD = Space$(8)
  CopyMemory ByVal MKD, value, 8
End Function

' Convert from String to Double

Function CVD(arg As String) As Double
  If Len(arg) < 8 Then Err.Raise 13
  CopyMemory CVD, ByVal arg, 8
End Function

' Convert from Currency to String

Function MKC(value As Currency) As String
  MKC = Space$(8)
  CopyMemory ByVal MKC, value, 8
End Function

' Convert from String to Currency

Function CVC(arg As String) As Currency
  If Len(arg) < 8 Then Err.Raise 13
  CopyMemory CVC, ByVal arg, 8
End Function

' Convert from Date to String

Function MKDt(value As Date) As String
  MKDt = Space$(8)
  CopyMemory ByVal MKDt, value, 8
End Function

' Convert from String to Date

Function CVDt(arg As String) As Date
  If Len(arg) < 8 Then Err.Raise 13
  CopyMemory CVDt, ByVal arg, 8
End Function

' Convert from Variant to String
' IMPORTANT: don't use for Variants holding strings, arrays or objects

Function MKV(value As Variant) As String
  MKV = Space$(16)
  CopyMemory ByVal MKV, value, 16
End Function

' Convert from String to Variant
' IMPORTANT: don't use for Variants holding strings, arrays or objects

Function CVV(arg As String) As Variant
  If Len(arg) < 16 Then Err.Raise 13
  CopyMemory CVV, ByVal arg, 16
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.