Results 1 to 28 of 28

Thread: Pointers, like in C?

Threaded View

  1. #22
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Pointers, like in C?

    Well a VB string is stored as a BSTR, if you would use VarPtr on a VB String you would get the address of the BSTR, which is a pointer to a pointer of the string. The StrPtr however will get the address of the first Unicode character in the string.

    The origional pointer (the pointer that points to the pointer that points to the characters, hmm... Pointers to Pointers are confusing) doesn't change. However if you assign a new value to the string a new string is created and the StrPtr in the string is changed to point to that location. The reason your StrPtr is changing is because you constantly give it a new value (which happens to be exactly the same text, but that string is recreated in every loop turn) inside the loop.

    I drawed a simple image for you that probably explains this a lot better.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width