1. Welcome to Tacoma World!

    You are currently viewing as a guest! To get full-access, you need to register for a FREE account.

    As a registered member, you’ll be able to:
    • Participate in all Tacoma discussion topics
    • Communicate privately with other Tacoma owners from around the world
    • Post your own photos in our Members Gallery
    • Access all special features of the site

C# help

Discussion in 'Technology' started by TacoNut, Jan 28, 2010.

  1. Jan 29, 2010 at 9:22 AM
    #21
    Chickenmunga

    Chickenmunga Nuggety

    Joined:
    Apr 10, 2008
    Member:
    #5877
    Messages:
    7,576
    Gender:
    Male
    First Name:
    Mike
    Keizer, Oregon
    Vehicle:
    08 TRD Offroad DC 4x4 with stuff
    All the normal TW BS
    This is the most important thing I read here:

    That means you are in a class, which means you have a teacher. Unless your teacher is a total d-bag, TAKE THE INITIATIVE TO TALK TO YOUR TEACHER.
    In college, I never did that, I always placed the blame and burden on myself. I never got to know my teacher, and my teacher never got to know me. They couldn't determine what I was struggling at, and couldn't impassion me with learning.
    Later, they couldn't help me with choosing Junior and Senior projects because they didn't know what I was good at or what my passions were. I got stuck with a horrific project that I was terrible at, and it made my grade suffer as a result. By the time I was forced to get help, I didn't know how to ask and they didn't know how to answer the questions in ways that were meaningful to me.

    There's nothing wrong with asking here, but if I can urge you, please make that connection. You will do much better, have a more enjoyable school year, the benefits are numerous. It's also pretty cool to find the professors who are willing to buy beer and pizza after class on Fridays, too :cool:
     
  2. Feb 17, 2010 at 7:24 PM
    #22
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,237
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    This is really good advice, I've actually gone and talked to him a couple of times... really easy since, well we have simmilar intrests.
     
  3. Feb 17, 2010 at 7:26 PM
    #23
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,237
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    on another note i've been looking at this for an hour or so and I can't figure out what I have wrong....

    My problem is btnCalc isn't calculating the stats right... I think I'm not defining dblTotal right, but I can't figure out for the life of me how to do it.

    PHP:
    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 
    Project4
    {



    public 
    partial class frmMain Form
    {
    //Data members
    int intLimit 0;
    int intCount 0;
    double dblAvg 0;
    double dblTotal 0;
    int intHigh 0;
    int intLow 999;
    int intScore 0;
    string strClass "";
    DateTime dtmDate DateTime.Today;
    //End Data Members

    public frmMain()
    {
    InitializeComponent();
    }
    private 
    void frmMain_Load(object senderEventArgs e)
    {
    int intcount 0;
    //Date Label
    DateTime dtmCurrent DateTime.Today;
    lblDate.Text dtmCurrent.ToString("D");

    //Loop
    for (intcount 0intcount 4intcount++)
    {
    switch (
    intCount++)
    {
    case 
    0lstClass.Items.Add("Freshman");
    break;
    case 
    1lstClass.Items.Add("Sophmore");
    break;
    case 
    2lstClass.Items.Add("Junior");
    break;
    case 
    3lstClass.Items.Add("Senior");
    break;
    }
    }

    //Focus
    lstClass.SelectedIndex = (0);
    txtScore.Focus();

    }
    private 
    void btnExit_Click(object senderEventArgs e)
    {
    Application.Exit();
    }
    private 
    void btnAbout_Click(object senderEventArgs e)
    {
    MessageBox.Show("This is Project 4 for CIS220 Section 2.","About");
    }
    private 
    void btnCalc_Click(object senderEventArgs e)
    {
    //set Count & Total to 0
    intCount 0;
    dblTotal 0;

    //while the counter is less than the limit
    //Assign the counter to the SelectedIndex of the score ListBox
    //Assign the score from the score ListBox to the score data member (convert to double from the SelectedItem of the score ListBox)
    //Add the score to the total
    //Increment the counter by 1.
    while (intCount intLimit)
    {
    lstScore.SelectedIndex intCount;
    intScore Convert.ToInt32(lstScore.SelectedIndex);
    dblTotal dblTotal Convert.ToDouble(intScore);
    intCount++;
    }
    dblAvg dblTotal intCount;
    txtTotal.Text dblTotal.ToString("G");
    txtCount.Text intCount.ToString("G");
    txtAvg.Text dblAvg.ToString("N");
    intCount 0;

    //Assign the counter to the SelectedIndex of the score ListBox
    //Assign the score from the score ListBox to the score data member
    do
    {
    intCount lstScore.SelectedIndex;
    intScore Convert.ToInt32(lstScore.SelectedIndex);

    if (
    intScore intLow)
    intLow intScore; }
    if (
    intScore intHigh)
    intHigh intScore; }
    intCount++;
    //Assign the High Score to the High Textbox, ToString(G).
    txtHigh.Text intHigh.ToString("G");
    //Assign the Low Score to the Low Textbox, ToString(G).
    txtLow.Text intLow.ToString("G");
    //Assign the SelectedItem from the Class ListBox to the Class data member.
    strClass Convert.ToString(lstClass.SelectedIndex);
    }
    while (
    intCount intLimit);
    txtMessage.Text "These scores are from the " strClass " Class.";
    }
    private 
    void btnGet_Click(object senderEventArgs e)
    {
    //Clear Message Box
    txtMessage.Clear();
    //Try Catch-Block
    try
    {
    intScore Convert.ToInt32(txtScore.Text);
    if (
    intScore <= 100)
    {

    lstScore.Items.Add(intScore);
    intLimit++;
    }
    else
    {
    MessageBox.Show("Invalid Entry: Score cannot exceed 100%""Error");
    }
    }
    catch {
    MessageBox.Show("Invalid Entry: Score is non-numeric""Error");
    }
    //Clear/Focus Score.Text
    txtScore.Clear();
    txtScore.Focus();

    }

    private 
    void btnReset_Click(object senderEventArgs e)
    {
    //Assign a value of zero to intLimit, intCount, dblTotal, dblAverage, intHigh, intScore
    intLimit 0;
    intCount 0;
    dblTotal 0;
    dblAvg 0;
    intHigh 0;
    intScore 0;
    //Assign a value of 999 to intLow
    intLow 999;
    //Assign a value of space to strClass.
    strClass "";
    //Clear the following textboxes: Total, Count, Average, High, Low, Message, and Score.
    txtTotal.Clear();
    txtCount.Clear();
    txtAvg.Clear();
    txtHigh.Clear();
    txtLow.Clear();
    txtMessage.Clear();
    txtScore.Clear();
    //Clear the Score ListBox.
    lstScore.Items.Clear();
    //Assign a value of zero to the SelectedIndex property of the Class ListBox.
    lstClass.SelectedIndex 0;
    //Set the focus on the Score Textbox.
    txtScore.Focus();
    }

    }
    }
     
  4. Feb 17, 2010 at 8:03 PM
    #24
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,237
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
  5. Feb 17, 2010 at 11:36 PM
    #25
    XrunnIT

    XrunnIT Well-Known Member

    Joined:
    Jul 6, 2008
    Member:
    #7770
    Messages:
    845
    Gender:
    Male
    Austin, TX
    Vehicle:
    1GR-GZE X-Runner
    Built Motor by LC Engineering Boosted by TRD
    when you say its not calcing right, is it a mathematical error? or is it throwing an error?

    do a debug and step your way through each variable, and see where the mistake is happening.
     
  6. Feb 18, 2010 at 8:01 AM
    #26
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,237
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    It's calculating wrong, I'll go ahead and run through it again... maybe a night of sleep will help
     
  7. Feb 18, 2010 at 8:16 AM
    #27
    NetMonkey

    NetMonkey Well-Known Member

    Joined:
    Aug 14, 2008
    Member:
    #8536
    Messages:
    1,734
    Gender:
    Male
    Geogetown, TX
    Vehicle:
    2010, 4x4, DC, off-road, shortbed, automatic
    Toytec Ultimate Lift @ 3", Mickey Thompson MTZ's 285/75/16, Moto Metal 955b, rear 2" ALL, Marlin Crawler sliders
    this is odd/unusual:

    Code:
    [COLOR=#ff8000][COLOR=#ff8000]//Loop[/COLOR]
    [COLOR=#007700]for ([/COLOR][COLOR=#0000bb][COLOR=darkorchid]intcount[/COLOR] [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]intcount [/COLOR][COLOR=#007700]< [/COLOR][COLOR=#0000bb]4[/COLOR][COLOR=#007700]; [/COLOR][COLOR=#0000bb]intcount[/COLOR][COLOR=#007700]++)[/COLOR]
    [COLOR=#007700]{[/COLOR]
    [COLOR=#007700]switch ([/COLOR][COLOR=#0000bb][COLOR=darkorchid]intCount[/COLOR][/COLOR][COLOR=#007700]++)[/COLOR]
    [COLOR=#007700]{[/COLOR]
    [COLOR=#007700]case [/COLOR][COLOR=#0000bb]0[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]lstClass[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Items[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"Freshman"[/COLOR][COLOR=#007700]);[/COLOR]
    [COLOR=#007700]break;[/COLOR]
    [COLOR=#007700]case [/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]lstClass[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Items[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"Sophmore"[/COLOR][COLOR=#007700]);[/COLOR]
    [COLOR=#007700]break;[/COLOR]
    [COLOR=#007700]case [/COLOR][COLOR=#0000bb]2[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]lstClass[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Items[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"Junior"[/COLOR][COLOR=#007700]);[/COLOR]
    [COLOR=#007700]break;[/COLOR]
    [COLOR=#007700]case [/COLOR][COLOR=#0000bb]3[/COLOR][COLOR=#007700]: [/COLOR][COLOR=#0000bb]lstClass[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Items[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000bb]Add[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"Senior"[/COLOR][COLOR=#007700]);[/COLOR]
    [COLOR=#007700]break;[/COLOR]
    [COLOR=#007700]}[/COLOR]
    [COLOR=#007700]}[/COLOR][/COLOR]
    
    why would you increment your counter variable on the switch statement. was that intentional? have you traced through that bit of code?

    also, you have a case sensitive issue here too. i am not even sure if this would compile.


    EDIT:
    nevermind... i see that you have those variables defined above. still, its very unusal.
     
  8. Feb 18, 2010 at 8:27 AM
    #28
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,237
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    I agree that it is odd, however this is how the professor wanted it done. He wanted us to learn a for loop while using something we've already done such as populating a list box.
    Usually I would just populate it without using a loop.
     
  9. Feb 18, 2010 at 8:42 AM
    #29
    chris4x4

    chris4x4 With sufficient thrust, pigs fly just fine. Moderator

    Joined:
    May 8, 2008
    Member:
    #6497
    Messages:
    112,751,674
    Gender:
    Male
    First Name:
    FlimFlubberJAM
    Tenoe, AZ
    Vehicle:
    2019 Rubicon 4 Door,
    4.10 gears, sliders, and lots of buttons.
    Maybe you should focus more on your classes, than your distillery?
     

Products Discussed in

To Top