Post: [Source] Random Number Generator
12-14-2011, 02:19 AM #1
Pichu
RIP PICHU.
(adsbygoogle = window.adsbygoogle || []).push({});
Random Number Generator.
UPDATED! ADDED VIDEO TUTORIAL!

How to use:
Select your Maximum and Minimum
Select how many times you want a number generated
Press generate

A list of randomly generated based on how many times you want it to generate will appear in the box on the right, when it is complete you will be prompted with a message box telling you it is completed.

This is great to use when you have to generate more than one random number, EG a raffle on here with 10 winners. Instead of using Random.Org and pressing it 10 times you can just generate all at once.

Difficulty: 1/10

Time taken: 10 minutes

Download to .exe file: You must login or register to view this content.

Video Tutorial: Added 12/23/11


You must login or register to view this content.


Source:

        
Random rnd = new Random();
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
numericUpDown1.Enabled = false;
numericUpDown2.Enabled = false;
numericUpDown3.Enabled = false;
button1.Enabled = false;
int a = Convert.ToInt32(numericUpDown1.Value);
int b = Convert.ToInt32(numericUpDown2.Value);
int c = Convert.ToInt32(numericUpDown3.Value);
for (int counter = 1; counter <= c; counter++)
{
int num = rnd.Next((b - 1), (a + 1));
if (num < 0)
{
num = num * -1;
}
richTextBox1.Text = num + "\n" + richTextBox1.Text;
if (counter == c)
{
button1.Enabled = true;
numericUpDown1.Enabled = true;
numericUpDown2.Enabled = true;
numericUpDown3.Enabled = true;
MessageBox.Show("Number of generated numbers is " + c, "Completed");
}
}
}


private void checkvalue_Tick(object sender, EventArgs e)
{
if (numericUpDown2.Value >= numericUpDown1.Value)
{
numericUpDown1.Value = numericUpDown2.Value + 1;
}
}
}


As you can see it is a very simple program, to those who are learning hopefully this code teaches you something.
Last edited by Pichu ; 12-23-2011 at 10:22 PM.

The following user thanked Pichu for this useful post:

Docko412

The following user groaned Pichu for this awful post:

CodingNation
12-15-2011, 07:04 AM #38
Originally posted by Sublimity View Post
Sent it to you, I downloaded it like 2 months ago so yea, it's probably history in the premium section by now..

would it be possible to code a youtube account maker in C#?
12-15-2011, 07:12 AM #39
Pichu
RIP PICHU.
Originally posted by YoutubeBotter View Post
would it be possible to code a youtube account maker in C#?


Yes, but I don't know much of anything with httpwebrequest for receiving and sending information yet, I think to learn and make something like that should be my goal over winter break, I'll start on it next week after I complete finals.
12-15-2011, 07:49 AM #40
tokzikate
Gym leader
hahaha i know, but it would be good to get one for free, a bunch of people on HF social engineered the most expensive one, I'm gonna stick to social engineering V energy drinks Smile
Originally posted by Sublimity View Post
Alienware is overpriced brand crap, you know you could self build the same or better models of alienware and get it for about 2/3 of the price, just won't have that alienware cover (Although you could probably get it on the internet for cheap somewhere)
12-15-2011, 12:58 PM #41
BuC-ShoTz
TeamMvKâ?¢
Originally posted by Sublimity View Post
Yes, but I don't know much of anything with httpwebrequest for receiving and sending information yet, I think to learn and make something like that should be my goal over winter break, I'll start on it next week after I complete finals.

just using a webBrowser controll and HtmlElement
    
private void webBrowser2_step1(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser2.Document.GetElementById("Email").SetAttribute("value", email_user + "@censored.com");
webBrowser2.Document.GetElementById("Passwd").SetAttribute("value", email_pass);
webBrowser2.Document.GetElementById("PasswdAgain").SetAttribute("value", email_pass);
webBrowser2.Document.GetElementById("Birthday").SetAttribute("value", m_birthdate + "/" + d_birthdate + "/" + y_birthdate);
webBrowser2.Document.GetElementById("loc").SetAttribute("value", "US");

HtmlElementCollection htmlElementCollection = webBrowser2.Document.GetElementsByTagName("img");
foreach (HtmlElement htmlElement in htmlElementCollection)
{
if (htmlElement.GetAttribute("src").Contains("https://accounts.google.com/Captcha"))
{
pictureBox2.ImageLocation = htmlElement.GetAttribute("src");
}
}

webBrowser2.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(webBrowser2_step1);
}


    private string GenerateName(NameType nameType)
{
List<string> names;
switch (nameType)
{
case NameType.First:
names = firstNames;
break;
default:
names = lastNames;
break;
}

Random randomNumbers = new Random();
int secretNumber = randomNumbers.Next(1, names.Count);

string name = names[secretNumber];
return name;
}

private List<string> lastNames = new List<string>()
{
"abbott",
"adams",
"adkins",
"aguilar",
"alexander",
"allen",
"allison",
"alvarado",
"alvarez",
"anderson",
"andrews",
"armstrong",
"arnold",
"atkins",
"austin",
"bailey",
"baker",
"baldwin",
"ball",
"ballard",
"banks",
"barber",
"barker",
"barnes",
"barnett",
"barrett",
"barton",
"bass",
"bates",
"beck",
"becker",
"bell",
"bennett",
"benson",
"berry",
"bishop",
"black",
"blair",
"blake",
"boone",
"bowen",
"bowers",
"bowman",
"boyd",
"bradley",
"brady",
"brewer",
"bridges",
"briggs",
"brock",
"brooks",
"brown",
"bryan",
"bryant",
"buchanan",
"burgess",
"burke",
"burns",
"burton",
"bush",
"butler",
"byrd",
"cain",
"caldwell",
"campbell",
"cannon",
"fitzgerald",
"fleming",
"fletcher",
"flores",
"flowers",
"floyd",
"ford",
"foster",
"fowler",
"fox",
"francis",
"frank",
"franklin",
"frazier",
"freeman",
"french",
"fuller",
"garcia",
"gardner",
"garner",
"garrett",
"garza",
"george",
"gibbs",
"gibson",
"gilbert",
"gill",
"girard",
"glover",
"gomez",
"gonzales",
"gonzalez",
"goodman",
"goodwin",
"gordon",
"graham",
"carlson",
"carpenter",
"carr",
"carroll",
"carson",
"carter",
"casey",
"castillo",
"castro",
"chambers",
"chandler",
"chapman",
"chavez",
"christensen",
"clark",
"clarke",
"clayton",
"cobb",
"cohen",
"cole",
"coleman",
"collier",
"collins",
"colon",
"conner",
"cook",
"cooper",
"copeland",
"cortez",
"cox",
"craig",
"crawford",
"cross",
"cruz",
"cummings",
"cunningham",
"curry",
"curtis",
"daniel",
"daniels",
"davidson",
"davis",
"dawson",
"day",
"dean",
"delgado",
"dennis",
"diaz",
"dixon",
"douglas",
"doyle",
"drake",
"duncan",
"dunn",
"edwards",
"elliott",
"ellis",
"erickson",
"estrada",
"evans",
"farmer",
"ferguson",
"fernandez",
"fields",
"figueroa",
"fisher",
"grant",
"graves",
"gray",
"green",
"greene",
"greer",
"gregory",
"griffin",
"griffith",
"gross",
"guerrero",
"gutierrez",
"guzman",
"hagel",
"hale",
"hall",
"hamilton",
"hammond",
"hampton",
"hansen",
"hanson",
"hardy",
"harmon",
"harper",
"harrington",
"harris",
"harrison",
"hart",
"harvey",
"hawkins",
"ayes",
"haynes",
"henderson",
"henry",
"hernandez",
"herrera",
"hicks",
"higgins",
"hill",
"hines",
"hockney",
"hodges",
"hoffman",
"hogan",
"holland",
"holloway",
"holmes",
"holt",
"hopkins",
"horton",
"houston",
"howard",
"howell",
"hubbard",
"hudson",
"huff",
"hughes",
"hunt",
"hunter",
"ingram",
"jackson",
"jacobs",
"james",
"jefferson",
"jenkins",
"jennings",
"jensen",
"jimenez",
"johnson",
"johnston",
"jones",
"jordan",
"joseph",
"keller",
"kelley",
"kelly",
"kennedy",
"kim",
"king",
"klein",
"knight",
"lamb",
"lambert",
"lane",
"larson",
"lawrence",
"lawson",
"lee",
"leonard",
"lewis",
"lindsey",
"ling",
"little",
"lloyd",
"logan",
"long",
"lopez",
"love",
"lowe",
"lucas",
"luna",
"lynch",
"lyons",
"mack",
"maldonado",
"malone",
"mann",
"manning",
"marsh",
"marshall",
"martin",
"martinez",
"mason",
"massey",
"mathis",
"matthews",
"maxwell",
"may",
"mcbride",
"mccarthy",
"mccormick",
"mccoy",
"mcdaniel",
"mcdonald",
"mcgee",
"mcguire",
"mckenzie",
"mckinney",
"mclaughlin",
"medina",
"mendez",
"mendoza",
"meyer",
"miles",
"miller",
"mills",
"mitchell",
"montgomery",
"moody",
"moore",
"morales",
"moran",
"moreno",
"morgan",
"morris",
"morrison",
"morton",
"moss",
"mullins",
"munoz",
"murphy",
"murray",
"myers",
"nash",
"neal",
"nelson",
"newman",
"newton",
"nguyen",
"nichols",
"norman",
"norris",
"norton",
"nunez",
"o'brien",
"oliver",
"olson",
"ortega",
"ortiz",
"osborne",
"owen",
"owens",
"padilla",
"page",
"palmer",
"park",
"parker",
"parks",
"parsons",
"patrick",
"patterson",
"patton",
"paul",
"payne",
"pearson",
"pena",
"perez",
"perkins",
"perry",
"peters",
"peterson",
"phelps",
"phillips",
"pierce",
"pittman",
"poole",
"pope",
"porter",
"potter",
"powell",
"powers",
"pratt",
"price",
"quinn",
"ramirez",
"ramos",
"ramsey",
"ray",
"reed",
"reese",
"reeves",
"reid",
"reyes",
"reynolds",
"rhodes",
"rice",
"richards",
"richardson",
"riley",
"rios",
"rivera",
"robbins",
"roberson",
"roberts",
"robertson",
"robinson",
"rodgers",
"rodriguez",
"rodriquez",
"rogers",
"romero",
"rose",
"ross",
"rowe",
"roy",
"ruiz",
"russell",
"ryan",
"salazar",
"sanchez",
"sanders",
"sandoval",
"santiago",
"santos",
"saunders",
"schmidt",
"schneider",
"schultz",
"schwartz",
"scott",
"sharp",
"shaw",
"shelton",
"sherman",
"silva",
"simmons",
"simon",
"simpson",
"sims",
"singleton",
"smith",
"snyder",
"soto",
"sparks",
"spencer",
"stanley",
"steele",
"stephens",
"stevens",
"stevenson",
"stewart",
"stokes",
"stone",
"strickland",
"sullivan",
"summers",
"sutton",
"swanson",
"tate",
"taylor",
"terry",
"thomas",
"thompson",
"thornton",
"tobias",
"todd",
"torres",
"townsend",
"tran",
"tucker",
"turner",
"tyler",
"underwood",
"valdez",
"vargas",
"vasquez",
"vaughn",
"vega",
"wade",
"wagner",
"walker",
"wallace",
"walsh",
"walters",
"walton",
"ward",
"warner",
"warren",
"washington",
"waters",
"watkins",
"watson",
"watts",
"weaver",
"webb",
"weber",
"webster",
"welch",
"wells",
"west",
"wheeler",
"white",
"wilkerson",
"wilkins",
"williams",
"williamson",
"willis",
"wilson",
"wise",
"wolfe",
"wong",
"wood",
"woods",
"wright",
"yates",
"young",
"zimmerman"
};
}
Last edited by BuC-ShoTz ; 12-15-2011 at 01:07 PM.

The following user thanked BuC-ShoTz for this useful post:

Correy
12-15-2011, 01:13 PM #42
Correy
I'm the Original
Originally posted by reScript
strTok is not defned :p

I made you it though because a wuv you Gaspkay:
    
public string[] strTok(string input, char spliter)
{
char[] text = input.ToCharArray();
string[] output = { };
string current = "";
for (int i = 0; i < text.Length; i++)
{
if (text[i] != spliter)
current += text[i];
if (text[i] == spliter)
{
output[output.Length + 1] += current;
current = "";
}
}
return output;
}


ha, too much GSC :yuno:

---------- Post added at 01:13 PM ---------- Previous post was at 01:11 PM ----------

Originally posted by tokzikate View Post
Nice, cleanly written program sublime Smile


---------- Post added at 02:11 AM ---------- Previous post was at 02:07 AM ----------

I don't know much about C# but would it be easier if it grabbed the first names, and lastnames, from a txt file?
One txt file for firstnames, and another for lastnames?
That you could have more variety in generated names, and a program that is easier to read Smile
But then again, you know what your doing Winky Winky as your a much better programmer than myself :P


it looks much neater when its all in the .exe, looks horrible when a program has loads of files :p
12-15-2011, 01:53 PM #43
BuC-ShoTz
TeamMvKâ?¢
Originally posted by reScript
strTok is not defned :p


    
private string[] strTok(string input, char splitter)
{
string[] tokens = input.Split(splitter);
return tokens;
}


List is better though, no need to split
My Lists contain 2889 First Names and 505 Last Names,
splitting that much is taking more time then to just load up a list.
I havent tested the speeds though... could be wrong

with List you can also add new objects on the fly
with array[] you have to create a new array everytime you want to add something, then copy it
Last edited by BuC-ShoTz ; 12-15-2011 at 02:11 PM.
12-15-2011, 09:24 PM #44
tokzikate
Gym leader
hey sublime, sorry to annoy you again, but would you mind telling me the title of that ebook, so I can see if I can find it?
or if you are bored you could even PM it to me Winky Winky
haha anyway thanks Smile
Originally posted by Sublimity View Post
I'm still learning the language, I could give you some tips and such if you need as well as link you to a great pdf for C# learning, I got to chapter 12 on it and it does a pretty good job of explaining, didn't finish it as I don't feel like reading that much, (Over 1000 pages).
12-16-2011, 05:31 AM #45
Pichu
RIP PICHU.
Originally posted by reScript
Alienware is not too that over-priced the graphic cards in them are ****ing beast and worth about £800 themselves.


If it is worth around 800 then you buy that and buy the rest of the parts needed and bam, you have a better computer for the same price or the same computer for less...
12-16-2011, 08:22 AM #46
Pichu
RIP PICHU.
Originally posted by reScript
Well yea of course, how else would the company make money? :p


...stare true true.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo