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

Why do I get "type fault" error with Array creation:

Status
Not open for further replies.

Riku

Programmer
Sep 2, 2001
119
0
0
Why do I get "type fault" error with:
' *********************************************
Dim nameArray()
Redim Preserve nameArray(3)
nameArray = Array("User_name","Password", "Bill_Company")
' *********************************************
I Copied it from a book.

I do not want to use nameArray(1) = x style couse my array is long like 24 elements.

F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
In this case, you can try delete "redim" part. So, you'll have something like this:

Dim nameArray
'Redim Preserve nameArray(3)
nameArray = Array("User_name","Password", "Bill_Company")

Good luck,
 
No luck still not working!
I made wery simple test page.
The hole code is below:
Could some one test if it works for them?
Could it be something that mys PWS 4 not support this
array creation style?

<html>
<head>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 4.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<title>New Page 1</title>
</head>
<body>
<%@ Language = &quot;VBscript&quot; %>
<%
dim test()
'Redim Preserve test(3)
test = Array(&quot;first&quot;,&quot;second&quot;,&quot;third&quot;)
%>
</script>
</body>

</html> F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Try:

Dim nameArray()
Redim Preserve nameArray(3)
nameArray = Split(&quot;User_name,PassWord,Bill_Company&quot;,&quot;,&quot;)

Hope this helps,
s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
First.
This does not work in VB6 because you can not Preserve an empty array. I assume VBScript is the same.
Try this
Dim nameArray()
Redim nameArray(3)

Second
Array must have a Variant as target, not an array of variants (Dim Test() is an array of variants)
Try this.
Dim Test
test = Array(&quot;first&quot;,&quot;second&quot;,&quot;third&quot;)

 
Thank I got it to work.
I changed the declaration of array variable to variable type.

Strange that asp book gave different example witch did not work.

Thanks! F: Riku Tuominen
riku.tuominen@benchmarking.fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top