Click here to Skip to main content
15,844,602 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult8-May-12 19:39
mvePIEBALDconsult8-May-12 19:39 
GeneralRe: C# dice program (combobox selection) Pin
Angel_789-May-12 3:55
Angel_789-May-12 3:55 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult9-May-12 4:20
mvePIEBALDconsult9-May-12 4:20 
GeneralRe: C# dice program (combobox selection) Pin
Angel_789-May-12 6:53
Angel_789-May-12 6:53 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult10-May-12 4:09
mvePIEBALDconsult10-May-12 4:09 
GeneralRe: C# dice program (combobox selection) Pin
Angel_7810-May-12 7:07
Angel_7810-May-12 7:07 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult10-May-12 16:48
mvePIEBALDconsult10-May-12 16:48 
GeneralRe: C# dice program (combobox selection) Pin
Angel_7811-May-12 16:57
Angel_7811-May-12 16:57 
Ok, reading that link you gave me I got the comboBox working but I am missing something here when I add things to my button Frown | :(
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;

namespace Dice
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.DataSource = Enum.GetValues(typeof(DiceValue));
        }

        public enum DiceValue
        {
            [Description("3 sided die")] Three = 3,
            [Description("3 sided die")] Four = 4,
            [Description("3 sided die")] Five = 5,
            [Description("3 sided die")] Six = 6,
        }
    public class RollDice
    {
        public static int RandomDice(Int32 numberOfSides, Int32 numberOfTimes)
        {
            int total = 0;

            Random rndGen = new Random((int)DateTime.Now.Ticks);

            for (int i = 0; i < numberOfTimes; i++)
            {
                // Upperbound is exclusive so add 1 to the number of sides
                total = total + rndGen.Next(1, numberOfSides + 1);
            }
            return total;
        }
        }

    private void button1_Click(object sender, EventArgs e)
    {
        var dice = new RollDice();

        var numberOfSides = comboBox1.SelectedItem;

        var numberOfTimes = textBox1.Text;

        int result = dice(numberOfSides, numberOfTimes);

        result = (dice);

        richTextBox1.Text = (result).ToString();
    }    
    }
}

dice under my button is the problem, "is a 'variable' but used as a 'method'". I thought I could call that variable from the method above?
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult12-May-12 7:23
mvePIEBALDconsult12-May-12 7:23 
GeneralRe: C# dice program (combobox selection) Pin
Angel_7812-May-12 13:12
Angel_7812-May-12 13:12 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult13-May-12 6:31
mvePIEBALDconsult13-May-12 6:31 
GeneralRe: C# dice program (combobox selection) Pin
Angel_7813-May-12 11:09
Angel_7813-May-12 11:09 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult13-May-12 17:34
mvePIEBALDconsult13-May-12 17:34 
GeneralRe: C# dice program (combobox selection) Pin
Angel_7814-May-12 11:36
Angel_7814-May-12 11:36 
GeneralRe: C# dice program (combobox selection) Pin
PIEBALDconsult14-May-12 15:11
mvePIEBALDconsult14-May-12 15:11 
Questionerror on exiting form wit datagridview containing comboboxcell Pin
markoVVVV8-May-12 2:14
markoVVVV8-May-12 2:14 
AnswerRe: error on exiting form wit datagridview containing comboboxcell Pin
Eddy Vluggen8-May-12 6:03
professionalEddy Vluggen8-May-12 6:03 
AnswerRe: error on exiting form wit datagridview containing comboboxcell Pin
Apocalypse Now8-May-12 15:58
Apocalypse Now8-May-12 15:58 
QuestionReg: Loading text file(size 100 MB) in Richtextbox Pin
Member 23893798-May-12 2:00
Member 23893798-May-12 2:00 
AnswerRe: Reg: Loading text file(size 100 MB) in Richtextbox Pin
Luc Pattyn8-May-12 3:10
sitebuilderLuc Pattyn8-May-12 3:10 
AnswerRe: Reg: Loading text file(size 100 MB) in Richtextbox Pin
Pete O'Hanlon8-May-12 3:26
subeditorPete O'Hanlon8-May-12 3:26 
AnswerRe: Reg: Loading text file(size 100 MB) in Richtextbox Pin
Dave Kreskowiak8-May-12 4:21
mveDave Kreskowiak8-May-12 4:21 
AnswerRe: Reg: Loading text file(size 100 MB) in Richtextbox Pin
Alan N8-May-12 5:31
Alan N8-May-12 5:31 
QuestionProblem with dictionary Pin
Mark Vloerjans8-May-12 1:52
Mark Vloerjans8-May-12 1:52 
AnswerRe: Problem with dictionary Pin
Luc Pattyn8-May-12 3:16
sitebuilderLuc Pattyn8-May-12 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.