;
 ; ------------------------------------------------------
 ;        Mid$(sStr, lPos, 1) = Chr$(iChr)
 ;        MidI(sStr, lPos) = iChr
 ; ------------------------------------------------------
 ;
 ; Property Let MidI(sStr As String, ByVal lPos As Long, ByVal iChr As Integer)
 ;    CopyMemory ByVal StrPtr(sStr) + lPos + lPos - 2&, iChr, 2&
 ; End Property
 ;
 ; ------------------------------------------------------
;
 .486            ; 32-bit instruction set
 .model flat     ; Protected memory, 4GB limit
 .code           ; Start of code

Let_MidI proc near

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

   shl edx, 1         ; convert to byte position
   jbe _exitp         ; invalid insert pos (jcz)
   test ecx,ecx       ; validate string pointer
   jz _exitp          ; exit null string passed

   cmp edx,[ecx-4]    ; compare pos with str len
   ja _exitp          ; pos outside string bounds

   mov [ecx+edx-2],ax ; insert chr into position

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

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