Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.basic.visual.misc > #2000

Re: LongPtr

From GS <gs@somewhere.net>
Newsgroups microsoft.public.vb.general.discussion, comp.lang.basic.visual.misc
Subject Re: LongPtr
Date 2014-01-22 16:49 -0500
Organization A noiseless patient Spider
Message-ID <lbped0$3c7$1@dont-email.me> (permalink)
References <lbok72$81e$1@speranza.aioe.org> <lbokc8$81e$2@speranza.aioe.org> <lbotvi$r75$1@dont-email.me> <l5c0e9dbm4kj2vblc6rotcihc2v2r9nvu0@4ax.com>

Cross-posted to 2 groups.

Show all headers | View raw


> On Wed, 22 Jan 2014 12:09:03 -0500, GS <gs@somewhere.net> wrote:
>
>>> On 22/01/2014 14:22, Deanna Earley wrote:
>>>> Since when did VBA support LongPtr??
>>>> I've just noticed it in Excel (2010) VBA (7) and it's a recognised 
>>>> type.
>>>> 
>>>> It's nowhere to be seen in the object browser and there is no 
>>>> associated
>>>> vbVarType constant for it.
>>>> 
>>>> VBA7 is not .Net based either as other Vb.Net keywords and 
>>>> operators
>>>> aren't supported.
>>> 
>>> Oh, just VBA in Excel 2010 and 2013 apparently:
>>> http://msdn.microsoft.com/en-us/library/office/gg251378.aspx
>>> I'd much prefer LongLong on a 32-bit system though :(
>> 
>> Just to clarify...
>> 
>> LongPtr in VBA7 is supported for x64 versions of MS Office. When 
>> running x32 it won't matter if VBA is still v7 (AFAIK)!
>
> Don't feel that particularly "clarified" the LongPtr.
>
> I think you meant to say, one only needs to modify VBA code if it is
> required to run in a 64-bit version of Office. LongPtr is available
> for both 32-bit and 64-bit versions of Office using VBA7. 
>
> While it refers to an 'integer' type it should ONLY be used for
> pointers and handles.
>
> For years in previous versions of VBA and VB we have used a Long to
> hold a 32-bit pointer/address, to the point that they have become
> almost synonymous. Such thinking becomes a disaster when dealing with
> addresses in a mixed enviroment. 
>
> Obviously using LongPtr in a VBA module/macro you plan to migrate is 
> a good idea. It is also a good practice to start using it in the 
> newer 32-bit enviroment as well - a good reminder we are dealing with 
> a pointer/handle and NOT just a numerical datatype. (Unless of course
> you plan to still support previous VBA versions. <g>)

I pretty much agree with everything you say here. My understanding of 
its usage is to use conditional declares in code for backward 
compatibility when same code is used for both.

Also, I don't believe x32 office uses VBA7 as my understanding is it's 
x64 only, but I may be wrong about that since I haven't yet worked with 
any versions after 2007!
>
> The issue of using LongLong or Long as integer datatypes for
> calculations or storage in a mixed environment is a separate but
> related issue, due to scale. A LongPtr can be used mask the problem -
> allowing VBA to run without disaster - but results are likely to be
> surprising at best. <g>
>
> -ralph
> [* Note: Since VBA runs within the context of the Office version 
> using it, "environment" in this case means the version of Office 
> being used. Not the O/S or "system".]

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Back to comp.lang.basic.visual.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

LongPtr Deanna Earley <dee.earley@icode.co.uk> - 2014-01-22 14:22 +0000
  Re: LongPtr Deanna Earley <dee.earley@icode.co.uk> - 2014-01-22 14:25 +0000
    Re: LongPtr GS <gs@somewhere.net> - 2014-01-22 12:09 -0500
      Re: LongPtr ralph <nt_consulting@yahoo.com> - 2014-01-22 15:36 -0600
        Re: LongPtr GS <gs@somewhere.net> - 2014-01-22 16:49 -0500
          Re: LongPtr ralph <nt_consulting@yahoo.com> - 2014-01-22 16:11 -0600
            Re: LongPtr GS <gs@somewhere.net> - 2014-01-22 17:16 -0500
              Re: LongPtr Deanna Earley <dee.earley@icode.co.uk> - 2014-01-23 09:56 +0000
          Re: LongPtr Deanna Earley <dee.earley@icode.co.uk> - 2014-01-23 09:55 +0000
            Re: LongPtr GS <gs@somewhere.net> - 2014-01-23 10:41 -0500
      Re: LongPtr Tony Toews <ttoews@telusplanet.net> - 2014-01-22 15:03 -0700
        Re: LongPtr GS <gs@somewhere.net> - 2014-01-22 17:14 -0500
        Re: LongPtr ralph <nt_consulting@yahoo.com> - 2014-01-22 16:53 -0600
  Re: LongPtr GS <gs@somewhere.net> - 2014-02-24 17:21 -0500

csiph-web