Hi there.

I don't seem to be able to understand how to pass a pointer to a string to the api functions ZeroMemory and FillMemory.

Can someone elucidate what I am doing wrongly.

Thanks in advance.

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (Destination As Any, ByVal Length As Long)
  4. Private Declare Sub FillMemory Lib "kernel32.dll" Alias "RtlFillMemory" (Destination As Any, ByVal Length As Long, ByVal Fill As Byte)
  5.  
  6. Private Sub Command1_Click()
  7. Dim s$
  8. s = "8888888888888888888888888"
  9. ZeroMemory ByVal StrPtr(s), Len(s)
  10. Me.Print "s apres zeromemory: " & s
  11. 'this does work why, I want 25 zeros?
  12.  
  13. s = "8888888888888888888888888"
  14. FillMemory ByVal StrPtr(s), LenB(s), Asc("a")
  15. Me.Print "s apres fillmemory: " & s
  16. End Sub