Atendiendo la petición de un lector pidiéndome el código completo…
Public Class Form1 ''' <summary> ''' Complete code to test the frame reading values sample (last post) ''' PepLluis, 11/10/2011 ''' </summary> ''' <param name="sender"></param> ''' <param name="e"></param> ''' <remarks></remarks> Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load ' Simulate string frame with values Dim frame = "{W111}{M222}{F333}{S444}" ' define Label and textboxes Dim Label1 As New Label With {.Name = "Label1", .AutoSize = True, .Location = New Drawing.Point(12, 10), .Text = "Frame :" + frame} Dim TextBox1 As New TextBox With {.Name = "TextBox1", .Width = 60, .Location = New Drawing.Point(12, 30)} Dim TextBox2 As New TextBox With {.Name = "TextBox2", .Width = 60, .Location = New Drawing.Point(12, 50)} Dim TextBox3 As New TextBox With {.Name = "TextBox3", .Width = 60, .Location = New Drawing.Point(12, 70)} Dim TextBox4 As New TextBox With {.Name = "TextBox4", .Width = 60, .Location = New Drawing.Point(12, 90)} ' add controls to form Me.Controls.AddRange({Label1, TextBox1, TextBox2, TextBox3, TextBox4}) ' define char as fields separators and values iden Dim separators As Char() = {"{", "W", "M", "S", "F", "}"} ' get fields Dim fields As String() = ( From f As String In frame.Split(separators) Where f.Length > 0 ).ToArray ' get textBoxes names Dim textBoxesNames() = ( From Tbn As Object In Me.Controls Where Tbn.GetType.Name = "TextBox" Select CType(Tbn, TextBox).Name Order By Name ).ToArray ' assign values to textboxes For Index As Integer = 0 To textBoxesNames.Count - 1 Me.Controls.Item(textBoxesNames(Index)).Text = fields(Index) Next End Sub End Class
Regards! :-)
PepLluis,