Hi guys,
I am trying to use a For...Next loop to cycle through the rows in a DataRow to put them into an XML file. I have written the following code...
Code:
For count = 0 To 7
writer.WriteStartElement("Day")
writer.WriteElementString("Date", objWeeklyRow(count).Item("Date"))
writer.WriteElementString("Maximum", objWeeklyRow(count).Item("Maximum"))
writer.WriteElementString("Grass_Min", objWeeklyRow(count).Item("Grass_Min"))
writer.WriteElementString("Ten_Soil", objWeeklyRow(count).Item("Ten_Soil"))
writer.WriteElementString("Rainfall_Total", objWeeklyRow(count).Item("Rainfall_Total"))
writer.WriteElementString("Max_Intensity", objWeeklyRow(count).Item("Max_Intensity"))
writer.WriteElementString("Sunshine_Total", objWeeklyRow(count).Item("Sunshine_Total"))
writer.WriteElementString("Prevailing_Direction", objWeeklyRow(count).Item("Prevailing_Direction"))
writer.WriteElementString("Ave_Speed", objWeeklyRow(count).Item("Ave_Speed"))
writer.WriteElementString("Max_Gust", objWeeklyRow(count).Item("Max_Gust"))
writer.WriteElementString("Pressure", objWeeklyRow(count).Item("Pressure"))
writer.WriteElementString("Comment", objWeeklyRow(count).Item("Comment"))
writer.WriteEndElement()
Next count
When the code is getting compiled i get an error saying "Index was outside the bounds of the array" If I put the numbers to reference the row in the parentheses (instead of the variable 'count') it works as it should but I wish to loop the procedure otherwise I will have pages and pages of repeated code.
Does anyone have any ideas what I am doing wrong??
Regards
Mark Edwards