parse multiline textbox

EStallworth

Well-known member
Joined
Aug 14, 2006
Messages
75
Location
Destin, FL
Programming Experience
Beginner
I am using a multiline textbox to receive data from a database and display the values for the user. What I need to do is find a way to execute operations on the values. Is there a way to read each individual value within the cells and assign them to variables?¿ I will include my code though I am not sure how it would be too useful.

VB.NET:
[SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click[/SIZE]
[SIZE=2]DataSet481.Clear()[/SIZE]
[SIZE=2]SqlDataAdapter1.Fill(DataSet481)[/SIZE]
 
[SIZE=2]TextBox1.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(0).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox2.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(1).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox3.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(2).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox4.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(3).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox5.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(4).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox6.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(5).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox7.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(6).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox8.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(7).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox9.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(8).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox10.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(9).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox11.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(10).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox12.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Columns(11).ColumnName & ControlChars.CrLf[/SIZE]
 
[SIZE=2]TextBox1.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox2.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox3.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox4.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox5.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox6.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox7.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox8.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox9.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox10.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox11.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
[SIZE=2]TextBox12.Text &= [/SIZE][SIZE=2][COLOR=#800000]"-----------"[/COLOR][/SIZE][SIZE=2] & ControlChars.CrLf[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox1.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(0) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox2.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(1) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]teger[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox3.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(2) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox4.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(3) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox5.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(4) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox6.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(5) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox7.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(6) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox8.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(7) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox9.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(8) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox10.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(9) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]I[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]nteger[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox11.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(10) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] rowloopindex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] (DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows.Count - 1)[/SIZE]
[SIZE=2]TextBox12.Text &= DataSet481.Tables([/SIZE][SIZE=2][COLOR=#800000]"Daily"[/COLOR][/SIZE][SIZE=2]).Rows(rowloopindex).Item(11) & ControlChars.CrLf[/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] rowloopindex[/SIZE]
 
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
A TextBox doesn't have cells. It contains one long string. A TextBox is a bad choice to display tabular data. In VB 2005 you have the DataGridView or, for simpler cases, the ListView. I strongly recommend that you use one of those controls.
 
A TextBox doesn't have cells. It contains one long string. A TextBox is a bad choice to display tabular data. In VB 2005 you have the DataGridView or, for simpler cases, the ListView. I strongly recommend that you use one of those controls.

Yeah I meant the cells which I am loading from the DB to the TB. I have since changed my scheme to include listboxes instead and am currently working on devising a way to sum up the rows within. CAN ANYONE HELP?¿
 
Last edited:
Back
Top