Sunday, April 27, 2014

Random lottery number generator.

sorry this is the actual code and im using 2 listbox's



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
//create array for numbers
const int NUMBER = 5;
int[] randomNumbers = new int[NUMBER];

//declare a streamwriter variable
StreamWriter outputFile;

//create the file, get streamwriter object
outputFile = File.CreateText("Values.txt");

//create random object
Random rand = new Random();

//write the arrays contents to the file
int index;
for (index = 0; index < randomNumbers.Length; index++)
{
randomNumbers[index] = rand.Next(100);


No comments:

Post a Comment