locked
For loop with textbox names RRS feed

  • Question

  • Hi.

    I'm new to VB.Net and right now I've got a problem with a little guitar tablature program I'm making.

    I've got a bunch of textboxes, named in the following way...

    txt1_String1 -> txt2_String1 -> txt3_String1 -> etc

    I'm using 'dbNotesRow.Item("StringPos1") = txt1_String1.Text' to add it to a database, and want to use a For loop so the txt1_String1 increments upto txt2, txt3 and so forth.

    Can anyone tell me if this is possible, and how to do it? Thanks a lot.
    Thursday, December 11, 2008 11:18 PM

Answers

  • Hi Josh .

    Yeah, everything is possible with VB .


    Dim I As Integer = 1
    Dim Max As Integer = 10
    Do While I <= Max
    dbNotesRow.Item(String.Format("StringPos{0}", I ) ) = Me.Controls(String.Format("txt{0}_String1", I ) ).Text
    I += 1
    Loop


    Best Regards,

    BVS.


    BVS, Cos(), Sin() Can Make The Miracles
    • Marked as answer by Joshuu Friday, December 12, 2008 12:35 AM
    Thursday, December 11, 2008 11:34 PM

All replies

  • Hi Josh .

    Yeah, everything is possible with VB .


    Dim I As Integer = 1
    Dim Max As Integer = 10
    Do While I <= Max
    dbNotesRow.Item(String.Format("StringPos{0}", I ) ) = Me.Controls(String.Format("txt{0}_String1", I ) ).Text
    I += 1
    Loop


    Best Regards,

    BVS.


    BVS, Cos(), Sin() Can Make The Miracles
    • Marked as answer by Joshuu Friday, December 12, 2008 12:35 AM
    Thursday, December 11, 2008 11:34 PM
  • Thanks for the quick answer, that seems to be working!
    Friday, December 12, 2008 12:35 AM