how to fill a datagridview with a split

0

make a split of a combobox that contains a strig like this (xy '+ xz)' + x ' and that I fill the grid with the columns xy', xz and x the string can contain n number of letters.

Public Sub split()
    Dim input As String = Me.txtfuncion.Text.ToString() & Convert.ToChar(8)
    Dim pattern As String = "(y)(x)(%+)"
    Dim items() As String = input.Split(pattern) 'c')
    'Dim cod As String = item(0)
    Dim cantidad As Integer = 0
    cantidad = items.Count - 1

Try
    For Each result As String In items(cantidad)

    Next
Catch ex As Exception
    MsgBox("ingrese una expresion algebraica")
End Try



End Sub
    
asked by user47575 14.06.2017 в 04:35
source

1 answer

0

If you want to get the variable names of the expression (extract the sets of letters) you can use regular expressions.

Assuming that the DataGridView has a sufficient number of columns, it could be something like this:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim input = txtfuncion.Text
    Dim regVars = new Regex("\w+")
    Dim matches = regVars.Matches(input)
    DataGridView1.Rows.Add(matches.Cast(Of Match).Select(Function(m) m.Value).ToArray())
End Sub
    
answered by 14.06.2017 в 09:18