Вы можете сделать этот бит короче:
For y as integer = 1 to 5
For y = 1 to 5
И тогда вы можете полагаться на тот факт, что ваш элемент управления имеет имена, которые отличаются только числом, и существует некоторая их коллекция, которая знает их по имя:
For y = 1 To 5
Dim n = "TxtStringNumP" & y 'formulate the name
Dim c = Me.Controls.Find(n, True) 'find all controls with a matcing name, returns a collection of controls
sw.WriteLine($"[{n}]") 'write the name we formulated
sw.WriteLine(c(0).Text) 'write the text of the first control. All controls have a Text property, we don't need to convert it to textbox
Next