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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a VBScript Array?

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
Don't laugh to hard. LOL I can't for the life of me figure out how to create an array out of a recordset. I've tried:

rs.MoveFirst
i = 0
EngMake = New Array(rs.RecordCount)
EngMake(i) = rs.Fields("Make").value & "|"
i = i + 1
rs.MoveNext

What am I doing wrong?
Rob
Just my $.02.
 
Dim EngMake(10)
"did you just say Minkey?, yes that's what I said."

MrGreed
 
I've tried Dim EngMake(rs.RecordCount) but that doesn't work. Rob
Just my $.02.
 
You can't use the "rs.RecordCount",

Do this:

Dim EngMake(0)

then

i=rs.RecordCount

redim preserve EngMake(i) "did you just say Minkey?, yes that's what I said."

MrGreed
 
I am using Remote Scripting with this. That may be part of my problem. I'm using the MsgBox on the Client to check the results. This in JavaScript works:

rs.Open(sql, cn, 3, 3);
i = 0;
EngMake = new Array(rs.RecordCount);
do
{
EngMake = rs.Fields("Make").Value;
i = i + 1;
rs.MoveNext();
}
while(!rs.EOF);
return EngMake;

That works. I get the results I need to fill combo boxes in the MsgBox.
The VBScript below comes back with a blank MgsBox with or without the Return:

rs.MoveFirst
Dim FillEngMake(rs.RecordCount)
for i = 0 to rs.RecordCount
FillEngMake(i) = rs.Fields("Make").Value & ","
i = i + 1
rs.MoveNext
Next
Return FillEngMake

It may have something to do with Remote Scripting. I can go through the RecordSet with a for each loop(VBScript) and I get the correct information, but I can't use the Split function. I get a type mismatch runtime error.

I also need to be able to check the Array. If the name is already in the array, I need to skip it and go to the next. If I have to use JavaScript, I guess I'll have to live with it.

Hope that makes a little more sense. Rob
Just my $.02.
 
Forgive the italcs. I don't know what I did to get that to happen? Rob
Just my $.02.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top