Passing an incremented modulus as a parameter, I think

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!
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top