Numeric UpDown For loop

Lums

Member
Joined
Feb 9, 2010
Messages
22
Programming Experience
Beginner
how would i ggo about coding this


For i = 0 To maxrows - 1
For h = 1 To maxrows
Me.Controls.Item("TextBox" & h).Text = ds.Tables("TestCriteria").Rows(i).Item(0)
Me.Controls.Item("NumericUpDown" & h).Value = ds.Tables("TestCriteria").Rows(i).Item(1)

Next
Next

that line is the problem
 
Since you haven't specified anything about why it's not working I'm just going to pull a random suggestion out of my ***

I see you're not converting it to a Decimal when assigning it to the NumericUpDown which should throw a compiler error (assuming you've turned Option Strict On, like you should have):
VB.NET:
Me.Controls.Item("NumericUpDown" & h).Value = Convert.ToDecimal(ds.Tables("TestCriteria").Rows(i).Item(1))
 
Ah, now that's something to go on, try this:
VB.NET:
CType(Me.Controls.Item("NumericUpDown" & h), NumericUpDown).Value = Convert.ToDecimal(ds.Tables("TestCriteria").Rows(i).Item(1))
 
thanks that worked perfectly

but im having another problem, its only calling data from my first row and filling all the textboxes with the same data

heres the code im using now

For Me.i = 0 To maxrows - 1
For Me.h = 1 To maxrows
Me.Controls.Item("TextBox" & Me.h).Text = ds.Tables("TestCriteria").Rows(Me.i).Item(0)
CType(Me.Controls.Item("NumericUpDown" & Me.h), NumericUpDown).Value = Convert.ToDecimal(ds.Tables("TestCriteria").Rows(Me.i).Item(1))

Next
Next
 
Back
Top