Datagrid contents to textbox

I have a datagrid that is retuirning some email addresses from a postgresql database...
I need to take the datagrid contents and copy it to a textbox on the form...only seperating each address with a comma...form mails these users...

My question is how do I get each row into a textbox? seperated by a comma?

datgrid control looks like this

I want to put that in a textbox like:,,

Who is Participating?
Shiju SasidharanAssoc Project ManagerCommented:
try this

Private Sub FillTextBox(ColumnIndex As Integer)
    Dim i
    Text1.Text = ""
    For i = 0 To DataGrid1.ApproxCount - 1
        DataGrid1.row = i
        DataGrid1.col = column
        If Text1.Text = "" Then
            Text1.Text = DataGrid1.Text
            Text1.Text = Text1.Text & ", " & DataGrid1.Text
        End If
    Next i
End Sub

Private Sub Command1_Click()
'    To get first column
     Call FillTextBox(0)
'       To get Second column
'       Call FillTextBox(1)
End Sub

DonVFAuthor Commented:
Or better yet....
Why the heck won't this work?

Dim rscount As Integer
rscount = adoPrimaryRS.RecordCount

For i = 0 To rscount
  Text1.Text = Text1.Text & adoPrimaryRS(i) & "," <---getting error on this line shown below
Next i

End Sub

Everything is there and it counts correctly...and can return emails...

The error is:
Runtime error 3265
Item can not be found in the collection corresponding to the requested name or ordinal.

DonVFAuthor Commented:
well..filles the textbox then errors...saying invalid row number...8(
DonVFAuthor Commented:
blah an on error statement fixed it hehe
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.