Hi i have a datatable. I have the following code. Is there a way that i can set the datarows to a module so that i can easily recall them. At the moment every calculation that is made i need to identify the datarows ie
Dim row1 as datarow = dt.rows(0)

I have tried putting these at the top of the code but no luck.

Thankyou.

        Function ADD(ByVal a As Single, ByVal b As Single) As Single

        Dim c As Single
        c = a + b
        Return c

        End Function

        'Can i move these to a module?

        Dim row1 As DataRow = dt.Rows(0)
        Dim row2 As DataRow = dt.Rows(1)
        Dim row3 As DataRow = dt.Rows(2)

        row3("C") = add(Row1("A"),row2("B")

where is dt inititalized? You can easily do it. It's the same as putting it at the front of your code. But if dt can't be read then it won't work. There's a pretty good post on global variables here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.