記得以前 QBasic 時代
有 MKSMBF$ , MKDMBF$
   CVSMBF , CVDMBF .... 等等函數功能就是例如 : Dim A As Single
A = 123.123
C$ = MKSMBF$(A) ---> 將傳回一個 4 byte 的字串A = CVSMBF(C$) ----> 將 C$ 解碼返回成 原先的 123.123 值==========================
VB6 已經沒有這些含數了
所以 自己想看看能不能模仿一下
如下程式
==========================
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Any, ByVal Source As Any, ByVal Length As Long)Function Var_To_Str(ptr As Long, Bytes As Integer) As String    Dim memory As String
        
    memory = String(Bytes, 0)
    
    Dim A As Byte, w As Long
            
    For w = 1 To Bytes
    
      A = 0
      
      CopyMemory VarPtr(A), ptr + w - 1, 1
      
      Mid$(memory, w, 1) = Chr(A)
      
    Next
   
    Var_To_Str = memoryEnd FunctionSub Str_To_Var(Aim$, 欲存入變數_Ptr As Long, Bytes As Integer)        
    Dim A As Byte, w As Long
      
     
    For w = 1 To Bytes
    
      A = Asc(Mid(Aim$, w, 1))
      
      CopyMemory 欲存入變數_Ptr + w - 1, VarPtr(A), 1
      
    NextEnd SubFunction Str_To_AscW$(Aim$, wall$)   ' 字串 串列 轉成 AscII 串列    Dim show As String
    
    show = ""
    
    For w = 1 To Len(Aim$)
    
        show = show & AscW(Mid$(Aim$, w, 1))
        
        show = show & wall$
        
    Next
    Str_To_AscW$ = Left(show, Len(show) - Len(wall$))
    
End FunctionPrivate Sub Command1_Click()Dim B As Long
B = 2 ^ 24 + 2 ^ 16 + 2 ^ 8 + 2 ^ 0  '----> OK 轉換無誤B = 12345 '----> OK 轉換無誤B = 65536 + 1000 '----> 轉換 錯誤
Command1.Caption = BC$ = Var_To_Str(VarPtr(B), Len(B)) ' B 轉成 字串Text1.Text = Str_To_AscW$(C$, ",") ' 將 4個字元組成的 C$ 分開顯示 , 以便觀察B = 0 ' 清空 , 看看 B 能不能回到原值Call Str_To_Var(C$, VarPtr(B), Len(B))  '  字串 轉回 B , 看看 B 是不是回到原來的 數值Text2.Text = B  '看看 B 是不是回到原來的 數值
C$ = Var_To_Str(VarPtr(B), Len(B))Text3.Text = Str_To_AscW$(C$, ",")End Sub