Link to home
Start Free TrialLog in
Avatar of indy500fan
indy500fan

asked on

Is there a more simple way to set a text field in this case?

Friends,

I have the following block of code, but I am hoping there is a more simple way to set the textbox?

Here is the code:

    Private Sub SetValueOfPosition(ByVal FinalBasePayout, ByVal Position)

        Select Case Position

            Case 1
                txt1.Text = FinalBasePayout

            Case 2
                txt2.Text = FinalBasePayout

            Case 3
                txt3.Text = FinalBasePayout

           '... Repeat for Cases 4 through 29

            Case 30
                txt30.Text = FinalBasePayout
        End Select

    End Sub

There has to be a more efficient way than this method that takes over 65 lines of code!

Thanks in advance!

Regards,
Eric
Avatar of bchoor
bchoor
Flag of United States of America image


Dim txtBox As TextBox = CTYPE(Me.FindControl("txt" & Position.Tostring()), TextBox)
txtBox.Text = FinalBasePayout
ASKER CERTIFIED SOLUTION
Avatar of bchoor
bchoor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of indy500fan
indy500fan

ASKER

Bchoor,

I'll try it!  Thanks!
Works perfectly!  Thanks!