Re: copymemory basic question



J French wrote:
> Just for fun, it might be nice to have a SwapStr() routine using
> CopyMemory

Rhetorical? (That was the initial "answer" in the thread, of course.)

Private Sub SwapPtrs(s1 As String, s2 As String)
Static lpTmp As Long
lpTmp = StrPtr(s1)
Call CopyMemory(ByVal VarPtr(s1), ByVal VarPtr(s2), 4&)
Call CopyMemory(ByVal VarPtr(s2), lpTmp, 4&)
End Sub

--
Working Without a .NET?
http://classicvb.org/petition


.



Relevant Pages

  • Re: Random Sort
    ... Private Declare Sub CopyMemory Lib "kernel32" _ ... Private Sub ShuffleStringArray(ByRef a() As String) ... Dim temp As String ...
    (microsoft.public.vb.general.discussion)
  • Re: copymemory basic question
    ... Private Sub SwapPtrs1(s1 As String, ... Static lpTmp As Long ... > I am sorting string arrays this way myself. ...
    (microsoft.public.vb.winapi)
  • Re: copymemory basic question
    ... > using CopyMemory to copy or swap array elements. ... Private Sub SwapPtrs(s1 As String, ... Static lpTmp As Long ...
    (microsoft.public.vb.winapi)
  • Re: copymemory basic question
    ... >> Private Sub SwapPtrs(s1 As String, ... >> Static lpTmp As Long ... Static locals are the way to avoid stack variables and still remain structured. ...
    (microsoft.public.vb.winapi)
  • Re: String Array Insert
    ... What's the obsession with CopyMemory? ... Private Sub SwapPtrs(s1 As String, ... Static lpTmp As Long ...
    (microsoft.public.vb.general.discussion)

Loading