Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 955209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:20:37+00:00 2026-05-16T00:20:37+00:00

FINAL EDIT: It does indeed appear to be a compiler bug – see the

  • 0

FINAL EDIT: It does indeed appear to be a compiler bug – see the accepted answer.

Using VBA within Excel 2007, I have the following code in ‘Class1’:

Option Explicit

Public Function strange(dummy As String, ParamArray pa())
    Debug.Print pa(LBound(pa))
End Function

Public Sub not_strange(dummy As String, ParamArray pa())
    Debug.Print pa(LBound(pa))
End Sub

Public Function also_not_strange(ParamArray pa())
    Debug.Print pa(LBound(pa))
End Function

and some mode code in a module:

Option Explicit

Public Function not_strange_either(dummy As String, ParamArray pa())
    Debug.Print pa(LBound(pa))
End Function

Public Sub outer(v)
    Dim c As Class1
    Set c = New Class1

    Call c.strange("", v(LBound(v)))
    Call c.not_strange("", v(LBound(v)))
    Call c.also_not_strange(v(LBound(v)))

    Call not_strange_either("", v(LBound(v)))
End Sub

If call ‘outer’ from the Immediate window like this:

call outer(array("a"))

I get back output that seems strange:

 102085832 
a
a
a

It seems to matter whether the called routine is in a class module or not, whether it is a Sub or a Function, and whether or not there is an initial argument. Am I missing something about how VBA is supposed to work? Any ideas?

The strange number changes from run to run. I say “looks suspiciously like a pointer” because if I call this:

Public Sub outer2(v)
    Dim c As Class1
    Set c = New Class1

    Dim ind As Long
    For ind = LBound(v) To UBound(v)
        Call c.strange("", v(ind))
    Next ind
End Sub

like so:

call outer2(array("a","b","c"))

I get back output like:

 101788312 
 101788328 
 101788344 

It’s the increment by 16 that makes me suspicious, but I really don’t know. Also, passing a value, say by calling:

Call c.strange("", CStr(v(ind)))

works just fine.

EDIT: A little more info…If I assign the return value from ‘c.strange’ to something instead of throwing it away, I get the same behavior:

Public Sub outer3(v)
    Dim c As Class1
    Set c = New Class1

    Dim x
    x = c.strange("", v(LBound(v)))

    Call c.not_strange("", v(LBound(v)))
    Call c.also_not_strange(v(LBound(v)))

    Call not_strange_either("", v(LBound(v)))
End Sub

Interestingly, if I call my test routines as above, with an argument that results from calling ‘Array’, the supposed-pointer value changes. However, if I call it like this:

call outer([{1,2,3}])

I get back the same number, even if I make the call repeatedly. (The number changes if I switch to another app in Windows, like my browser.) So, now I’m intrigued that the Excel evaluator (invoked with the brackets) seemingly caches its results…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:20:38+00:00Added an answer on May 16, 2026 at 12:20 am

    Now this is awesome.

    Reproduced on office 2003.
    Looks like a compiler bug.

    The problem is in this line:

    Call c.strange("", v(LBound(v)))
    

    Here the compiler creates a Variant that holds a 1D array of Variant‘s, the only element of which is a pointer instead of the value. This pointer then goes to the strange function which actually is not strange, it only prints the Variant\Long value passed to it.

    This trick brings the compiler sanity back:

    Call c.strange("", (v(LBound(v))))
    

    EDIT

    Yes, this magic number is a pointer to the VARIANT structure which is supposed to be passed to the strange method. The first field of which is 8, which is vbString, and the data field contains a pointer to the actual string "a".

    Therefore, it is definitely a compiler bug… Yet another VB compiler bug in regard of arrays 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It basically calls into your dll (named filename.ax in this… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer Our problem turned out to be because of a new… May 16, 2026 at 12:45 pm
  • Editorial Team
    Editorial Team added an answer You could put the files you're working on in a… May 16, 2026 at 12:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Final Edit : The wall of text below can be summed up by simply
Edit : Note that my final purpose here is not having the class working,
The Java static compiler (javac) inlines some static final variables and brings the values
Update: I've added an answer that describes my final solution (hint: the single Expr
Say I have a method declaration like: private void someMethod(final String someKey, final Object
I'm using an FMT file to BCP a csv file into a an SQL
I've come into an interesting problem (as is often the case in interacting with
Language : C++ Platform : Windows Server 2003 I have an exe calling a
I'm trying to use C-h c in emacs to figure out what a key
I have given up tryng to figure out the reason of this issue, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.