vb.net - Find missing value in a numbers sequence - DGV column -


I tried to search and did not find any success in fixing my problem, so I tried to find my solution .

First I found the maximum (maximum) value (minimum value always 1), then I set the loop to search by value, but something is wrong in my loop. DataGridView1.Rows.Count- 1 if DataGridView1.Rows (y) .Cell (0):

  i as integer = 1 to max as y for integer = 0. Value = i then other builder 2 .Append (i & amp; ",") end if next next   

I look fine, but it is not working. If the value is found i then nothing is found. If it is not found, then add i to stringbuilder and, as long as it Maximum value is not reached But whatever I have tried I have achieved some strange results.

The number from lowest to highest

I have also removed all values ​​from the DGV column with a comma-delimited string if it is easy ...

Edit: Just to experiment with that loop I have put I = 40 to 50 (to reduce the border) I know that the missing values ​​in the DGV column are 40-46 and 59. With this loop upwards I have: You can use LINQ to easily find missing numbers

You just need to get the current numbers in one list, and then you can use maximum () to find the missing people, and except and .

I created a column, a name DGV named DGV with buttons of One button, bnPopulateDGV, and a new button named bnFindMissingNumbers on a new Windows form, and the following code ( with option ):

  personal sub bnPopulateDGV_Click (the form of the object) In the form of Sender, and EventArgs) handle bnPopulateDGV.DataGridView1.Rows.Clear () Dim seq1 = Enumerable.Range (1, 100) .Ooist () Dim Rand as New Random 'Knock Out For Some' I = 1 to 5 seq1.RemoveAt (rand.Next (0, 50)) for next each seq1 in DataGridView1.Rows.Add (new string () (s.ToString ()}) Next End Sub Private All bnFindMissingNumbers_Click (Object T as the sender, and eventArgs) handles bnFindMissingNumbers. Click the DataGridView1.Rows DataGridView1.Rows the current Numbers.Add (CInt (r.Cells (0) .View) in the DataGridViewRow for each of the diminished current digits (of the integer). Next D im min = 1 dim max = currentNumbers.Max ( ) Slim Recalculation = Numerical Category (min, max - min + 1). (Current number) MsgBox ("unavailable:" & string.joined (",", missing numbers)) sub    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -