Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays

Status
Not open for further replies.

sshafe

Programmer
Oct 18, 2002
71
US
I feel really dumb asking this, but I need some refreshing on how to set up dynamic arrays, how to populate them, and how to output them at the end.

Can someone give me a link or two that shows how to do this.

A little detail... I am reading in a file, placing it into the array and then want to ftp the results at the end, but I cannot remember array syntax.

Thanks in advance. :-/
 
May help

thread329-551015

____________________________________________________
[sub]get the best answer to your questions by asking the best questions "General FAQ" faq333-2924[/sub]
onpnt2.gif
[sub][sup][/sup][/sub]
 
I'm still not sure. I've looked at all those sites. Here is what I have written. Can you tell me what's wrong?

Option Explicit
Dim ErrogArrayLog()
Private Const NAME = 0
Dim i
Dim Add_InputFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim DataReadIn
Dim SplitInput
Dim strUserName
Dim strUserGroup
Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")
Set Add_InputFile = fso_OpenTextFile("c:\test_vbscript2.txt", ForReading)

i = 0

Do While Add_InputFile.AtEndOfStream = false

DataReadIn = Add_InputFile.ReadLine
SplitInput = Split(DataReadIn,vbTab)

If ubound(SplitInput)-lbound(SplitInput)<>1 then
LogFile.Write (&quot;User Invalid number of fields! Check Add user input file for : &quot; & DataReadIn )

Else
strUserName=SplitInput(0)
strUserGroup=SplitInput(1)
ErrorArrayLog(i) = strUserName

MsgBox ErrorArrayLog(i)
i = i + 1
End If


Loop
 
There are no error message, it just not populating the array, or if it is, it's not putting it out to the screen. (Which in the long run is not what I want to do anyway.) This code is just for testing purposes.
 
Let me clarify that. I will be using the code, just not outputting it to the screen. Instead using in generated code to ftp error messages.
 
have you checked to see if your array is being populated with anything?
try checking by adding the bolded line
DataReadIn = Add_InputFile.ReadLine
SplitInput = Split(DataReadIn,vbTab)
MsgBox UBound(SplitInput)
to your script

____________________________________________________
[sub]get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924[/sub]
onpnt2.gif
[sub][sup][/sup][/sub]
 
Yes, the input is coming back with a message box.
 
the message box states the number of elements in it?

are you sure this is the condition that you want
ubound(SplitInput)-lbound(SplitInput)<>1

lbound is always going to return 0. there's no otehr value to return if the array is populated with something.

why not jsut say
if UBound(SplitInput)<>1




____________________________________________________
[sub]get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924[/sub]
onpnt2.gif
[sub][sup][/sup][/sub]
 
I'm doing that because my input file has two fields that are tab delimited. So in order to split my fields, I set it up that way. Once I get all this worked out, I plan on putting it into a script that reads multiple files and outputs to a log file. When I get this to work, all I am going to populate the array with is any errors that occur when I try to insert or delete into a database. That way, I don't have to insert the whole log file into the ftp script. So the splitting won't be a part of of my array in the main script.

So what I am trying to do right now is probably a lot more difficult than what I will be doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top