mercredi 4 octobre 2017

how do i generate random number loop with fix char code in c#?

I have tried to generate the six digit random number in which first three numbers are changing with random number and last three digit is in number which is amount and converted in to ascii to character now problem is i want to generate every time new code with three new digit and three fix digit which i had entered and also i had a for loop for grid view in which a qty textbox now if i enter 5 qty random six digit code had to generate for every qty with different 3 digit and 3 fix digit here's the code

                    Random rnd = new Random();
                    string text3 = textBox1.Text;
                    string text4 = "";
                    char[] array = text3.ToCharArray();
                    foreach (char c in array)
                    {
                        int ascii = (int)c;
                        //ascii = ((((ascii / 37 + 657) / 12) - 582) / 11);
                        ascii += 23;
                        text4 += Convert.ToChar(ascii).ToString();
                    }

                    //text4 = Encoding.ASCII.GetString(text4);


                textBox2.Text = rnd.Next().ToString() + text4.ToString();


                }
                int i = 0;
              for (i = 0; i < int.Parse(qtytxt.Text); i++)
                {
                    int j = i + 1;

   dt.Rows.Add(label5.Text, comboBox1.Text, j, ratetxt.Text, Sizetxt.Text);
                }

                dataGridView1.DataSource = dt;  




Aucun commentaire:

Enregistrer un commentaire