how to create a temp table and store it as a global variable? (easy points)

hi all,
I have the following code:

  Private Sub cmdMiscellaneous_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdMiscellaneous.Click

        Dim dt As New DataTable
        dt = com.library.data.Tools.GetTableMaintenace()
        Dim dtrw As DataRow
        dtrw = dt.Rows(0)
        For Each dtrw In dt.Rows
            Dim pattern As String = "T\d{2}"
            For Each m As Match In Regex.Matches(strRights, pattern)
                If dtrw(3) = m.Value Then
                    MsgBox("Table Name: " & dtrw(2) & vbCrLf & "Form Name: " & dtrw(4))
                 End If
            Next
        Next

    End Sub

and what i need to do is to create a tmp datatable and store as a global variable for this i have set up a global variable called:

Public dtTemp As DataTable

how can i do this?
thanks,
jsctechy
LVL 1
jsctechyAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Create table and columns:

dtTemp = New DataTable("Matches)
dtTemp.Columns.Add("TableName")
dtTemp.Columns.Add("FormName")

Add a row:

 If dtrw(3) = m.Value Then
    Dim dr As DataRow = dtTemp.NewRow()
   dr("TableName") = dtrw(2)
   dr("FormName") = dtrw(4)
    dtTemp.Rows.Add(dr)
End If

Bob
0
 
jsctechyAuthor Commented:
so this code goes instead of the msgbox()  
????
0
 
jsctechyAuthor Commented:
also how can i display the values that dttemp holds after the execution?
0
 
Bob LearnedCommented:
Yes, no MsgBox.

For Each dr As DataRow In dtTemp.Rows
   For Each dc As DataColumn In dtTemp.Columns
      Console.WriteLine(dr(dc).ToString())
   Next dc
Next dr

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.