Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2022, 02:44 PM
macropod's Avatar
macropod macropod is offline Using .Net arrays in VBA crashes Word Windows 10 Using .Net arrays in VBA crashes Word Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


A trivial demonstration of using arrays in Word:

Code:
Sub Demo()
Application.ScreenUpdating = False
Dim MyArray() As String, i As Long, j As Long
For i = 10 To 1 Step -1
  ReDim Preserve MyArray(j)
  StrTxt(j) = i: j = j + 1
Next
MsgBox UBound(MyArray) ' Count of array elements (0-based)
MsgBox Join(MyArray(), ", ") ' Unsorted list of array elements
WordBasic.SortArray MyArray() ' Sort the array
MsgBox Join(MyArray(), ", ") ' Sorted list of array elements
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 11-08-2022, 08:04 PM
BrianHoard BrianHoard is offline Using .Net arrays in VBA crashes Word Windows 10 Using .Net arrays in VBA crashes Word Office 2019
Advanced Beginner
Using .Net arrays in VBA crashes Word
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Thank you Macropod, this is very helpful.
I see that I can work with an array of a single data type, is it possible to create an array of arrays? Where each array element is an array itself?

A goal structure like this, where the first 2 items in each array are ints, followed by a string.

multipleDataArrayName{
{1, 2, "some text"},
{3, 4, "some text2"},
etc
}

Then be able to access this info something like...
multipleDataArrayName(0)(2)
would return: some text2


Is this possible?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using .Net arrays in VBA crashes Word How to use arrays? Simplifier Excel 1 09-03-2016 03:50 AM
Create an input box for arrays rajani Word VBA 2 08-17-2015 06:28 AM
Variable arrays from user input SeattleITguy Excel Programming 1 01-29-2015 09:19 AM
Using .Net arrays in VBA crashes Word Searching Arrays without Loops? ptmuldoon Word VBA 3 12-13-2014 11:21 AM
Using .Net arrays in VBA crashes Word re-naming arrays in VBA? JDevsFan Excel Programming 4 03-15-2012 08:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:26 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft