Process textboxes through loop using their names & Index?

Jun 21 2017 4:15 AM
Suppose: Winform Contains following textboxes...

txtPrice01
txtPrice02
txtPrice03
txtPrice04
txtPrice05
....
....
txtPrice60


txtQty01
txtQty02
txtQty03
txtQty04
txtQty05
....
....
txtQty60

I am using following code...which did not work as required....


Dim ItemID As Integer() = {0, 1, 2, 61, 3, 62, 14, 13, 63, 12, 11, 64, 18, 16, 15, 65, 8, 66, 9, 10, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60}
Dim n as string

For i As Integer = 1 To 60
If i < 10 Then n = "0" + i.ToString() Else n = i.ToString()

txtQty = DirectCast("txtQty" + n, TextBox)
txtPrice = DirectCast("txtPrice" + n, TextBox)

txtQty.Clear()
txtPrice.Text = ITM.PriceSalesSP(ItemID(i))
Next

Answers (1)