;
 ; ------------------------------------------------------
 ;        Mid$(sStr, lPos, 1) = Chr$(iChr)
 ;        MidIp(lspStr, lPos) = iChr
 ; ------------------------------------------------------
 ;
 ; Property Let MidIp(ByVal lspStr As Long, _
 ;                    ByVal lPos As Long, _
 ;                    ByVal iChr As Integer)
 ;
 ;    CopyMemory ByVal lspStr + lPos + lPos - 2&, iChr, 2&
 ; End Property
 ;
 ; The position to write to is assumed to be within
 ; the allocated length of the specified string.
 ;
 ; ------------------------------------------------------
;
 .486           ; 32-bit instruction set
 .model flat    ; Protected memory, 4GB limit
 .code          ; Start of code

Let_MidIp proc near

   mov ecx,[esp+8]    ; copy string pointer
   mov edx,[esp+12]   ; copy pos parameter
   mov ax, [esp+16]   ; extract passed wchar

   test ecx,ecx       ; validate string pointer
   jz _exitp          ; exit null string passed
   shl edx, 1         ; convert to byte position
   jbe _exitp         ; invalid insert pos (jcz)
 
   mov [ecx+edx-2],ax ; insert char into position

  _exitp:
   xor eax, eax    ; clear eax tell VB all okay
   ret 16          ; cleanup (lpObj, p1, p2, p3)

Let_MidIp endp  ; end of procedure
end Let_MidIp   ; end of code, indicate entry point
