Hi, I'm having problems regarding using arrays on object names. for example, i have a textbox named txtBox1.text and a array declared as a(2). I what to transfer the value of the textbox to the array using loop. Here's my code that works.
This is the code or somewhat the code of what i want to doCode:'Checks if txt11N.text field is empty 'If txt11N.text has a value, checks if txtCat1.text has a value 'If txtCat1.text has a value, checks txt11P.text 'If all fields are filled up, transfers them to an array If txt11N.Text <> "" Then If txtCat1.Text = "" Then MessageBox.Show("Please fill in Category 1", "Error!", _ MessageBoxButtons.OK, MessageBoxIcon.Error) ' Else If txt11P.Text = "" Then MessageBox.Show("Please enter price of item 1.1", "Error!", _ MessageBoxButtons.OK, MessageBoxIcon.Error) Else Category(1) = txtCat1.Text Item1(1) = txt11N.Text End If End If End If
Code:'Checks if txt11N.text field is empty 'If txt11N.text has a value, checks if txtCat1.text has a value 'If txtCat1.text has a value, checks txt11P.text 'If all fields are filled up, transfers them to an array If txt11N.Text <> "" Then If txtCat1.Text = "" Then MessageBox.Show("Please fill in Category 1", "Error!", _ MessageBoxButtons.OK, MessageBoxIcon.Error) ' Else If txt11P.Text = "" Then MessageBox.Show("Please enter price of item 1.1", "Error!", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End If End If If Counter >= 4 Then Category(Counter) = txtCat(Counter).Text Item1(Counter) = txt1(Counter)N.Text Counter = counter+1 End if




Reply With Quote