Results 1 to 5 of 5
  1. #1
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    340

    Arrays - varinats and alternatives

    Can someone help with (or a link to) explanation between

    Dim xyz as variant


    Dim xyz () as Integer, or string ?
    Dim xyz (0)

    I nee to upskill a bit on arrays.
    Thanks.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I rarely use arrays; pretty much only when I have to use the Split() function. I use:

    Dim strInvoices() As String
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    340
    Aren't both Arrays? I find both work with Split.

  4. #4
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Dim xyz as Variant - This enables you to assign any type of value (String, Integer, Single, Double, Date etc.) to it. It will automaticaly change the data type when a particular value type is assigned to it.

    Dim xyz() as integer/String - Normal type of declaration is like Dim xyz(0 to 11) as Integer (or Dim xyz(1 to 12) - Assume that you want 12 elements in the Array to store 12 month's numbers. So, in this case we know exactly how many elements we need to store data.

    Dim xyz() as integer - declares that it is an Array of Integers but doesn't know how many elements are required, in advance. That will be known somewhere in the body of the program.

    When we calculate the number of elements then Re-dimension the Array to that maximum(n) number: ReDim xyz(0 to n-1) Integer or ReDim xyz(1 to n) as Integer in the body of the program.

    Dim xyz(0) - xyz(0) dimensioned as a variant array with a single element. You need to type three extra characters (0) to access it's contents. This is as good as a single variable xyz (Dim xyz)

  5. #5
    Middlemarch is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2015
    Posts
    340
    Thanks Apr, helpful. I'd always made an array as variant in the past.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. sql query arrays
    By drewdrew in forum Programming
    Replies: 3
    Last Post: 07-03-2014, 03:35 AM
  2. Instantiated Reports (or better alternatives?)
    By Dunro in forum Programming
    Replies: 12
    Last Post: 06-04-2013, 07:31 PM
  3. passing arrays io a report
    By Seamus59 in forum Reports
    Replies: 3
    Last Post: 05-21-2013, 10:51 AM
  4. Chart Limitations / Alternatives?
    By sainttomn in forum Reports
    Replies: 3
    Last Post: 09-09-2011, 02:56 PM
  5. Using DSN alternatives with MYSQL
    By ajetrumpet in forum Access
    Replies: 2
    Last Post: 10-14-2010, 12:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums