Results 1 to 6 of 6

Thread: How to Buffer a Variable??

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    NYC
    Posts
    52
    I *know* the answer to this; I just learned it a few days ago and now I can't remember.

    When I call an API function that uses a pointer to a variable, I'm supposed to buffer the variable before it gets there. I can't remember the function to set the length of the variable!

    e.g.
    Code:
    Dim sClsNm As String
    'something goes here like setlen(sClsNm, 25)
    Call GetClassName(hWnd, sClsNm, 25)
    debug.print(sClsNm)
    Will someone remind me?

    Thanks,
    --Josh

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I don't know if this works for your API, but it works for GetPrivateProfileString

    Dim sBuffer as String
    Dim sResult as String
    Dim nDummy as Integer

    sBuffer = Space$(99)
    nDummy = GetClassName(hWnd, sBuffer, 25)
    sResult = Left$(sBuffer, nDummy)

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    NYC
    Posts
    52
    that's the one. Thanks!

  4. #4

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    NYC
    Posts
    52
    Wait.. now how do I do it for a Long?

    Thanks,
    --Josh

  5. #5
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    a Long is always 45 Bytes. you can get the length of a variable in bytes using the LenB Function, eg
    LenB(lngMyLong) will always return 4. There's no need to buffer longs fo the API, It's only Strings you need to do.

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2000
    Location
    NYC
    Posts
    52
    ah. found my bug (I *knew* that wasn't supposed to be a Long).

    Thanks!

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