how to generate number and characters together randomly. I know how to generate numbers randomly, but not getting anywhere with random character generation.
If you can pick a random letter and you pick a random integer, you can pick a random letter or integer, depending on the probability distribution you want. An example:
for (int i = 0; i < stringLength; i++)
int randomNumber = /* number from 0 to 35 */
if (randomNumber < 10)
c = /* pick random digit */
c = /* pick random letter */
// add c to end of randomString
I really don't like all these hacks based on the internal representation of chars, and what about the non-alphanumeric chars that sit in spaces between the alphabetics in ASCII/Unicode? Here's a good Java way to do it:
Create a char array containing all the valid symbols you want to use (digits, upper/lower case letters, selected punctuation etc). Use your random integers as indexes into the array to select random chars.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...