Passing an incremented modulus as a parameter, I think

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone

I have a piece of code I was trying to convert over to VB.Net. I hoping
someone can help me out. I have a sub routine or function that creates a SQL
query string, creates a dataset, and creates a table. I create rows for that
table in another function. I also have a counter (vRowNumber) that counts the
row number of the table. What I wanted to know is how would I increment
vRowNumber(vRowNumber++) and perform a modulus calculation on vRowNumber in
VB.net. Take note that I am passing all this information as a parameter to
the CreateNameRow() function. Here is the code.

private void BuildNamesList()
{
string vSQL = "EXEC sp_Blah;
DataSet vNames = SQLAccess.GetDataSet(vSQL);
DataTable vNamesTable = vNames.Tables[0];

int vRowNumber = 0;
foreach (DataRow vRow in vNamesTable.Rows)
Textbox.Rows.Add(CreateNameRow(vRow, vRowNumber++%2 == 0));
}

Hope I explained myself clearly and thanks in advance for any assistance!
 
foreach (DataRow vRow in vNamesTable.Rows)
Textbox.Rows.Add(CreateNameRow(vRow, vRowNumber++%2 == 0));

For Each vRow As DataRow In vNamesTable.Rows
Textbox.Rows.Add(CreateNameRow(vRow, (vRowNumber Mod 2) = 0))
vRowNumber += 1
Next


Mattias
 
Back
Top