here is my code:

this is my select query where I concatenated the firstname, lastname, and middle initial..(and display it on the data grid)

  Private Sub DisplayListOfPosition()
    query = "SELECT profNo as 'No', CONCAT(profFName,', ', profLName, ' ', profMI,'.') as 'Name', profAddress 
    as 'Address', gender as 'Gender' FROM tbl_professor_bs"
    FillDBGrid(query, Me.dgvProfessor_bs)
    Me.txtProfNo_bs.Enabled = False
  End Sub

I used cellclick on the other forms so that the data in the grid would display in textboxes.. my problem is, how would I display the concatenated columns in different textboxes?
this is my code(unfinished):

Private Sub dgvProfessor_bs_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvProfessor_bs.CellClick
        Me.txtProfNo_bs.Text = Me.dgvProfessor_bs.Rows(e.RowIndex).Cells(0).Value.ToString()
        Me.txtProfFName_bs.Text = Me.dgvProfessor_bs.Rows(e.RowIndex).Cells(1).Value.ToString()
    End Sub

thank you in advance for your help! :)

Edited 3 Years Ago by ses03: wrong words


You've concatenated the fields in your query and you want to split them back out again?

You could try using the split function on the space character:

dim Names() as String

Names = dgvProfessor_bs.Rows(e.Rowindex).Cells(1).Value.Split(New Char() {" "c})

textboxFirstName.Text = Replace(Replace(Names(0), ",",""),".","")
TextboxLastName.Text = Replace(Replace(Names(1),",",""),".","")
TextboxMiddle.Text = Replace(Replace(Names(2),",",""),".","")

Edited 3 Years Ago by G_Waddell

This question has already been answered. Start a new discussion instead.