Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    class variable array (Word2000)

    <post:=407,423>post 407,423</post:>
    <post:=371,653>post 371,653</post:>
    www.visualbasicbooks.com

    Attached is the net result of my labours this morning.
    I am writing an application that traps save/open/close and builds an internal array of data.
    "Class Module" because the data must be available to the application on each re-entry, that is,
    the application springs into life, captures another item for the array, and then stops while the user does other stuff.
    The application re-starts on each Save/Close/Open.
    The Class module works fine, and I have managed to code (admittedly crude) demonstrations of

    1. <LI>Initializing the array "MRUse1"
      <LI>Loading the array "MRUse2"
      <LI>Obtaining an item from the array "MRUse3"
      <LI>Sort the array "MRUse4"
      <LI>Locate an item in the array "MRUse5"
      <LI>Return to the caller a copy of the array "MRUse6"
    I'm not happy with MRUse6 and wonder if anyone can suggest a better way.
    I'd rather hoped to do the equivalent of an array assignment, along the lines of <pre>myNewArray=pubMRUse.Array</pre>

    but VBA doesn't like array assignments. It seems.

    (from the class module for MRUse6)<pre>Public Function ArrayMe(mru() As mruStorageFileRecord)
    ReDim mru(UBound(myMRUSEArray))
    Dim lng As Long
    For lng = LBound(myMRUSEArray) To UBound(myMRUSEArray)
    mru(lng) = myMRUSEArray(lng)
    Next lng
    End Function</pre>

    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: class variable array (Word2000)

    What's wrong with

    Public Function ArrayMe() As mruStorageFileRecord()
    ArrayMe = myMRUSEArray
    End Function

    in the class module, and

    Sub MRUse6()
    ''' Execute this procedure to obtain a copy of the array
    Dim newMRUArray() As mruStorageFileRecord
    newMRUArray = pubMRUse.ArrayMe
    End Sub

    in the standard module?

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: class variable array (Word2000)

    >What's wrong with ...
    Nothing!
    Thanks!!
    I wish I'd kept my old code from very early this morning to see what I'd done wrong/differently.
    I'd swear it didn't work this morning.
    Obviously I'd tried something a little different ...

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: class variable array (Word2000)

    Hi Chris
    >I wish I'd kept my old code from very early this morning
    Oh how often I've said those same words. Consequently, I eventually developed two modules to handle this for me semi automatically.

    The attachment contains two modules: WDDev_1.bas; and XLDev_1.bas for Word and Excel respectively.

    Preparation (one time)
    <UL><LI>Create one or two folders to contain the backup code from your projects under development. A separate folder for each application.
    <LI>Place the WDDev_1.bas and XLDev_1.bas files in your Normal.dot and Personal.xls files respectively.
    <LI>In each of the modules, revise the Const BP = "D:CodeSafeVBE<Excel> or <Word>" line found in the ProtectCode procedure to agree with the path you have chosen to back up your code.
    <LI>Create a button (Development), in each of the applications to fire the "Dev_1_Main" procedure[/list]Preparation (change of project under development), in the "Dev_1_Main" procedure;
    <UL><LI>Change the Const sFile = "????" line to reflect the filename (less extension) of the project under development
    <LI>Change the Const sMacro = "Module.Procedure" line to reflect the procedure being called.[/list]Operation
    <UL><LI>Open the development project
    <LI>Click the Development button
    <LI>The code will be backed up, then the identified procedure will be run[/list]Backup
    <UL><LI>On the first use after launching the application, the code within each object of the project under development is saved in the backup folder.
    <LI>On each subsequent use, only revised modules are saved in the backup folder.
    <LI>Up to 99 archives of the most recent versions of any module are retained in the form of Module1_01.bas through Module1_99.bas Module1_01.bas being the most recent[/list]I hope that you find this useful.
    Attached Files Attached Files
    Regards
    Don

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: class variable array (Word2000)

    >The attachment contains two modules:
    Thanks Don, I'll take a look at these.
    Trouble is, i already have a versioning scheme - a button that opens a template, increments the version number (as part of the file name, saves the new version, opens the VBE window and maximizes it.
    I use it regularly and frequently during code development and maintenance, "numbers are free", and so Under415.dot --> Under416.dot --> Under417.dot. I use the 3-digit version number in my log of fixes, and maintain such a document "WhatFAQ" for each project. I am so organised!

    The other day, because I was doing a "quickie test" on a single piece of code, I wasn't versioning! My VBEUp macro is about as automated as it can net, but if I don't use it, it is use-less!

Posting Permissions

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