473,378 Members | 1,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

looping through the array

omerbutt
638 512MB
hi i am trying to declare an array and then initializing through a string and then displaying it with a for loop but i am gettin a "type mismatch error" at the line where i am using the split() function to initialize my array with the elements of the string
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim items, i, size,string
  3.             Dim Header(17)
  4.             string="CODE-NO,PART-NO,PRODUCT,BRAND,AUTO,UNIT-PRICE,SIZE,HEIGHT,OUT-DIA1,OUT-DIA2,IN-DIA1,IN-DIA2,REP-NO1,REP-NO2,REP-NO3,REP-NO4,REP-NO5,REP-NO6"
  5.             Header = split(string,",")
  6.             //Header()=Array("CODE-NO","PART-NO","PRODUCT","BRAND","AUTO","UNIT-PRICE","SIZE","HEIGHT","OUT-DIA1","OUT-DIA2","IN-DIA1","IN-DIA2","REP-NO1","REP-NO2","REP-NO3","REP-NO4","REP-NO5","REP-NO6")
  7.             size=[UBound(Header)-LBound(Header)]-1
  8.             Response.Write(size)
  9.             Response.End()
  10.             for i = 0 to size
  11.             Response.Write(size)
  12.             next
  13. %>
Nov 24 '07 #1
2 1170
Nicodemas
164 Expert 100+
You're getting this error because the Dim Header(17) statement declares Header as an array. (Line 3)

Then on Line 5, you are trying to assign a value to Header. As an array, no value can be directly assigned to Header. You would have to assign the value to an index of Header.

The solution is to not declare Header as an array, but rather as an empty variable. Once you assign the split() to Header, Header is now an array.



Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim items, i, size,string, header
  3. string="CODE-NO,PART-NO,PRODUCT,BRAND,AUTO,UNIT-PRICE,SIZE,HEIGHT,OUT-DIA1,OUT-DIA2,IN-DIA1,IN-DIA2,REP-NO1,REP-NO2,REP-NO3,REP-NO4,REP-NO5,REP-NO6"
  4. Header = split(string,",")
  5. //Header()=Array("CODE-NO","PART-NO","PRODUCT","BRAND","AUTO","UNIT-PRICE","SIZE","HEIGHT","OUT-DIA1","OUT-DIA2","IN-DIA1","IN-DIA2","REP-NO1","REP-NO2","REP-NO3","REP-NO4","REP-NO5","REP-NO6")
  6. size=[UBound(Header)-LBound(Header)]-1
  7. Response.Write(size)
  8. Response.End()
  9. for i = 0 to size
  10. Response.Write(size)
  11. next
  12. %>
Nov 28 '07 #2
omerbutt
638 512MB
yeah i already did taht thanks for helping any way tcz

You're getting this error because the Dim Header(17) statement declares Header as an array. (Line 3)

Then on Line 5, you are trying to assign a value to Header. As an array, no value can be directly assigned to Header. You would have to assign the value to an index of Header.

The solution is to not declare Header as an array, but rather as an empty variable. Once you assign the split() to Header, Header is now an array.



Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim items, i, size,string, header
  3. string="CODE-NO,PART-NO,PRODUCT,BRAND,AUTO,UNIT-PRICE,SIZE,HEIGHT,OUT-DIA1,OUT-DIA2,IN-DIA1,IN-DIA2,REP-NO1,REP-NO2,REP-NO3,REP-NO4,REP-NO5,REP-NO6"
  4. Header = split(string,",")
  5. //Header()=Array("CODE-NO","PART-NO","PRODUCT","BRAND","AUTO","UNIT-PRICE","SIZE","HEIGHT","OUT-DIA1","OUT-DIA2","IN-DIA1","IN-DIA2","REP-NO1","REP-NO2","REP-NO3","REP-NO4","REP-NO5","REP-NO6")
  6. size=[UBound(Header)-LBound(Header)]-1
  7. Response.Write(size)
  8. Response.End()
  9. for i = 0 to size
  10. Response.Write(size)
  11. next
  12. %>
Nov 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ensnare | last post by:
Hi all, I'm using a database session handler and am looking to loop through data residing in the sessions table to make a 'Users online' array. I've found that using urldecode on the data...
2
by: CanoeGuy | last post by:
I have an array that I am populating from a database. I am looping through the array to write the values to a datagrid. At this point, I'm stuck. I can't figure out how to read the first four...
1
by: Nicole | last post by:
Hello! I hope there is someone out there who can shed some light on this for me. I have a module that is supposed to look at an access table, pull out each bid record, link to another table to...
4
by: Sjoerd | last post by:
Summary: Use foreach(..) instead of while(list(..)=each(..)). --==-- Foreach is a language construct, meant for looping through arrays. There are two syntaxes; the second is a minor but useful...
11
by: Jim Whitaker | last post by:
Expand full for viewing... I have a parent/child table. The basic setup is as follows: The parent table is called load sheet. It has fields such as Tripno, carrier, loaddate, etc. The child...
11
by: motion musso aka: sathia | last post by:
this is it, how can i get the current index? couldn't figure it out. thank you for(i=0;myarray.length<i;i++){ do_something(); //i need the current myarray } bye bye
1
by: delraydog | last post by:
I have an associative array that I need to loop through, allbills, however, each element in this array requires processing by the user and I need to capture the users actions on the element and...
1
by: assgar | last post by:
Hello I have changed the process code abit so it receives the data from the form and ensures the data in array format. This has eliminated my previous error. The problem I am experiencing...
4
by: wbosw | last post by:
I'm trying to take a word (stEAdy) and find the index positions of the uppercase characters(2,3) in the word. I have them stored in an array (positionarray). Then I reverse the word and set all...
3
by: assgar | last post by:
Hi I am having problem with my loping. I don't know if I have chosen the correct approach. GOAL: I need to insert into a table event types for a specific date range. The calendar the event...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.