PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] SizeOf() VB6 Equivalent?-VBForums
Results 1 to 11 of 11

Thread: [RESOLVED] SizeOf() VB6 Equivalent?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    24

    Resolved [RESOLVED] SizeOf() VB6 Equivalent?

    I'm looking through the online MSDN for an equivalent to SizeOf() from C++... I need it for this:

    I'm making a VB TYPE version of this, but, I'm not sure how to fill cbsize with the SizeOf() for the struct.

    typedef struct tagMONITORINFO {
    DWORD cbSize;
    RECT rcMonitor;
    RECT rcWork;
    DWORD dwFlags;
    } MONITORINFO, *LPMONITORINFO;

    -or-

    So, does anyone know what I could use to replace SizeOf() or a safe number to hardcode into cbSize in place of SizeOf()?
    vb Code:
    1. Public Type RECT
    2.         Left As Long
    3.         Top As Long
    4.         Right As Long
    5.         Bottom As Long
    6. End Type
    7.  
    8. Private Type tagMONITORINFO
    9.     cbSize As Long
    10.     rcMonitor as RECT
    11.     rcWork As RECT
    12.     dwFlags as Long
    13. End Type

  2. #2
    Lurker
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: SizeOf() VB6 Equivalent?

    Dim t As tagMONITORINFO
    t.cbSize = Len(t)

  3. #3
    Lively Member
    Join Date
    Oct 2014
    Posts
    76

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    Note that the real size of the structure in memory may differ from what Len() returns because of 4-byte aligning in VB6. To have the correct size in bytes in memory, use LenB() instead of Len().

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,605

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    How and why did you find this topic to give a reply after 10 years?

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,221

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    Seems like good information, but I'm also wondering how you found the thread. Generally, we prefer if people left long dead threads where they lie. The others who posted in the thread might appreciate it, too, if they forgot to unsubscribe.
    My usual boring signature: Nothing

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,802

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    You know? I'll give my two-cents on this one. I'm not sure there's anything to do, but this is clearly one of those situations where maybe some software needs to be "re-thought". If I remember correctly, I made this same mistake when I first joined, just not noticing how old the thread was before I replied.

    And it seems that I see this happen maybe once every couple of weeks.

    I'm not sure if it's possible (in practical terms), but it might be nice to get a double-check warning when replying to a thread that's older than some pre-defined cutoff (possibly six months since the last reply).

    IMHO, it's certainly not the right approach to berate responders (not that we do) when they reply to an old thread, given that it's apparently an easy mistake to make. I'm not necessarily defending wisecat, but rather just pointing out that it's a somewhat frequent mistake, and that's often a flag that the tool (i.e., the software) can be improved.

    Best Regards,
    Elroy
    Last edited by Elroy; Feb 1st, 2017 at 12:11 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,221

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    I'm uncertain about this situation, myself, especially with this reply. In this case, the response was quite a valid point from a member who has been around for a time, which I'm pretty comfortable with. What raises flags is when a new member resurrects a thread with a post that is either a copy of another post in the thread or something fairly irrelevant.

    We do generally discourage the resurrection of threads long dead, because the people involved in the discussion have likely forgotten about it long ago. Certainly, it is unlikely that the OP, in this case, cares anymore, but the point made by wisekat would almost certainly be useful to anybody who came across the thread as a result of a search. Since Google generally does a better job of finding threads in this forum than the built in search functionality, and since Google/Bing/Whatever are so ubiquitous these days, I suspect that finding such threads is actually easier than ever, so it's a gray area (or grey, for some of you). One thing to keep in mind, though, is that lots of people subscribe to threads, which means they get an email whenever a reply is added to a thread. Some folks would then curse this reminder....though I personally think it's probably a good thing. It might prompt some people to return for a visit.

    So, Elroy, I'd say that you might start a thread over in forum feedback with that suggestion. I don't know whether or not it is possible, or even desirable, but I do think that it might start a worthwhile discussion.
    My usual boring signature: Nothing

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,802

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    Will do.

    I did notice that wisekat joined in 2014, but he also only has 24 posts, which suggests that he is sort of a newbie. I just like seeing new blood, especially if they're long-time VB6 programmers who just got interested in VBForums.

    And yes, regarding getting the emails, I'm also one of those people who fumes a bit when I get unwanted emails. However, I do have VBForums filtered to go to a special folder. I'm here often enough that I don't need them in my inbox.

    I'll start the thread though.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  9. #9
    Lively Member
    Join Date
    Oct 2014
    Posts
    76

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    Yes, I am a newbie on this forum - though I joined it about 3 years ago. Is it a problem if I post to old threads like this?

    I found this forum thread while working on my software. I googled "vb6 size of structure", and the link to this thread was the 1st (!) in Google's SERP. I opened it to see what people write about this topic on one of my favorite VB forums, and I saw that the answer was incomplete or incorrect in some situations. I decided to improve this with my post as it is the FIRST result on Google, which means that other developer may easily come to it and get an incomplete answer to their questions related to sizes of VB structures.

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    5,802

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    Hey Wisecat, I'll defer to Shaggy because he's the forum moderator. I can tell you though that you will get dinged by various members if you post to old threads often.

    Personally, I'm delighted to have new people start participating in the forums. We can always use some new blood. Maybe I'd just humbly recommend perusing the latest threads first though, which can be found here.

    Best Wishes,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    34,221

    Re: [RESOLVED] SizeOf() VB6 Equivalent?

    I felt that the addition was a good one. That latest post was kind of suggestive, too. We've seen lots of old threads resurface, of late, but as far as I can tell, this is ONLY happening in the VB6 forum. I wonder if VBF is bubbling to the top when it comes to VB6 questions, these days. Age may be creating an unanticipated SEO.

    I would say that useful information, which corrects a lingering inadequacy in an old thread, is still a good thing. This is even more true if the thread is popping up so high in searches.
    My usual boring signature: Nothing

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width