Solved

loading external multdimensional array from a .txt file

Posted on 2009-05-03
2
361 Views
Last Modified: 2012-05-06
how can i display arrays in vbscript from an external txt file (.txt)
assuming the data on the txt file looks like this

houseno streetname surburb
23 James westside
1 street somewhere
0
Comment
Question by:vbsnoob
2 Comments
 
LVL 10

Accepted Solution

by:
TakedaT earned 250 total points
Comment Utility
Something like this?

I always hated working with dynamic multidimensional arrays.  Not being able to redim the first dimension just makes it annoying.  I usually just go with 2 one dimensional arrays.
Const forReading = 1, forWriting = 2, forAppending = 8

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")

Dim arrAddresses()

strAddressFile = "address.txt"
 

Set readAddressFile = objFSO.OpenTextFile(strAddressFile,forReading)
 

i=0

Do while not readAddressFile.AtEndOfStream

	strLine = readAddressFile.ReadLine

	arrLine = split(strLine," ")

	ReDim preserve arrAddresses(2,i)

	arrAddresses(0,i) = arrLine(0)

	arrAddresses(1,i) = arrLine(1)

	arrAddresses(2,i) = arrLine(2)

	strAddresses = strAddresses & vbCrLf & arrAddresses(0,i) & vbTab & arrAddresses(1,i) & vbTab & arrAddresses(2,i)

	i=i+1

Loop
 

MsgBox strAddresses

Open in new window

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Remove Office macro by VC++ 10 69
Scan IP address, obtain info 7 69
If not exist vbs error 4 26
Running Visio Macro from VBS File 3 32
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now