Last post Sep 19, 2008 07:02 AM by GonKas
Sep 17, 2008 05:34 AM|GonKas|LINK
I'm trying to fill an array for calculation of my website visits but I don't understand how the arrays works! I've red severall tutorials and posts but they're written in C and I prefer VB.
The main ideia here is simply to get the values of a datagrid into an arraylist...
VisitasTotais.Text = ""
Dim dgItem As GridViewRow
Dim AcumulaPath(,) As ArrayList
Dim contador As Integer = 0
Dim VisitasTotal As Integer = 0
For Each dgItem In GridView1.Rows
VisitasTotal = VisitasTotal + Int(dgItem.Cells(4).Text)
AcumulaPath(contador, 0) = Int(dgItem.Cells(0).Text)
AcumulaPath(contador, 1) = Int(dgItem.Cells(1).Text)
AcumulaPath(contador, 2) = Int(dgItem.Cells(2).Text)
AcumulaPath(contador, 3) = Int(dgItem.Cells(3).Text)
contador = contador + 1
VisitasTotais.Text = VisitasTotal
Thanks in advance.
Sep 17, 2008 08:09 AM|DkUltra|LINK
Use a generic list eg. List(of integer) or List(or String)
Why is a multidimenional array needed ?
Hope this helps
Sep 17, 2008 12:24 PM|GonKas|LINK
Can you give me an example of List?
Multidimensional is needed because I want to create an array identical as the database.
Thanks for your help.
Sep 17, 2008 12:42 PM|DkUltra|LINK
MultiDimensioning is not needed
_Rowfild1 = value
_Rowfild2 = value
_Rowfild3 = value
_Rowfild4 = value
Next Load the list
tmp.field1 = row.field1
Sep 18, 2008 05:56 AM|GonKas|LINK
I appreciate your help but I think that contais errors for example:
- Namespace DataObjects, statements can occur only at file or namespace level;
- What's the purpose of Public Sub New() End Sub?;
- Next Load the list, Syntax error;
- Dim db As New ExampleDataContext, Type ExampleDataContext is not defined;
- Dim table, is missing the As;
- Dim NewList As New List(Of DataObjects.Example), List not defined.
I'm sorry but I'm novice and this is troubling me, lol! I'm still trying to migrate from ASP to ASP.NET 2.0 and previously this was much easier.
Sep 18, 2008 09:07 AM|DkUltra|LINK
I'm using vs2008 as such some of the syntax is different; to clear up some confusion what version are you using?
Namespace DataObjects, statements can occur only at file or namespace level; This is a separate class file
file(1) the data object
file(2) the routine that your using it from
- What's the purpose of Public Sub New() End Sub?; - nothing at this point, just a stub i usually put in
- Next Load the list, Syntax error; - just a comment telling you what to do eg. not intended to be included with the code
Basically, my example was using the paridigm that the data was coming from a database and not a datagrid like yours
but the concept is the same.
create a object to store the data and then store the item in a list.
- Dim db As New ExampleDataContext, Type ExampleDataContext is not defined; a vs2008 linq data access thing
- Dim table, is missing the As; vs2008 thing
- Dim NewList As New List(Of DataObjects.Example), List not defined. OK; add System.Collections.Generic.List(Of )
Hope this clears some things up.
We can take this step by step if needed.
Sep 19, 2008 07:02 AM|GonKas|LINK
Thanks for your reply.
I'm using Microsoft Visual Web Developer 2008.
The information you provide is good for me to start geeting deeper at code. So no need to kaet step by step.
Thanks for all the help.