Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

loading external multdimensional array from a .txt file

Posted on 2009-05-03
2
364 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
ID: 24293062
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

860 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