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 28, 2010 at 9:08 AM
    #1
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    Anyone here wouldn't happen to know a little bit about c#, would they?
     
  2. Jan 28, 2010 at 9:12 AM
    #2
    Mondwa

    Mondwa Well-Known Member

    Joined:
    Dec 22, 2009
    Member:
    #28028
    Messages:
    1,365
    Gender:
    Male
    First Name:
    Michael
    Phoenix, AZ
    Vehicle:
    08 V6 Tacoma
    remote start, Allpro bumper, Slimchubby HID, MetalMiller custom Emblem
    Do you mean C+ or C++? I dont know anything about it but what are you trying to do? I work on Cisco networks. Maybe i can help:confused:
     
  3. Jan 28, 2010 at 9:14 AM
    #3
    mjp2

    mjp2 Living vicariously though myself Moderator

    Joined:
    Feb 16, 2007
    Member:
    #924
    Messages:
    17,773
    Gender:
    Male
    First Name:
    Milton Juevos Portimous II
    NJ
    Vehicle:
    '06 TRD Access Cab, v6, 6-speed
    Scaffolding and a painted grill
    He means C#. It's a Microsoft .Net language.

    Yeah, I'm all over the stuff. Ask away.
     
  4. Jan 28, 2010 at 9:16 AM
    #4
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand

    Nope C#,

    I'm trying to basically calculate a running total, and average of a double

    PHP:
    private void btnDisp_Click(object senderEventArgs e)
    {
    //Calculate Amount
    Amount += Price;
     
     
    //Calculate Average
    Average = (Amount Count);
     
    //Display values
    txtCount.Text Count.ToString();
    txtAmt.Text Amount.ToString();
    txtAvg.Text Average.ToString();
    }


    basically trying to get something like this to work.
     
  5. Jan 28, 2010 at 9:20 AM
    #5
    jspadaro

    jspadaro Well-Known Member

    Joined:
    Jan 7, 2009
    Member:
    #12342
    Messages:
    2,994
    Gender:
    Male
    First Name:
    Jim
    Knoxville, TN
    Vehicle:
    Former Tacoma Owner
    Blue Oval Mod
    So what's the problem?
     
  6. Jan 28, 2010 at 9:21 AM
    #6
    chris4x4

    chris4x4 With sufficient thrust, pigs fly just fine. Moderator

    Joined:
    May 8, 2008
    Member:
    #6497
    Messages:
    106,158
    Gender:
    Male
    First Name:
    FlimFlubberJAM
    Tenoe, AZ
    Vehicle:
    2013 Rubicon Unlimited,
    4.10 gears, sliders, and lots of buttons.
    A Hippy fucking with computers.....we're fucked.
     
  7. Jan 28, 2010 at 9:23 AM
    #7
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    The Amount(sum) and Average aren't calculating/showing up. It still shows the values as zero. All the code seems to be right.

    Sorry I'm kind of new to this whole thing.
     
  8. Jan 28, 2010 at 9:23 AM
    #8
    98tacoma27

    98tacoma27 is gooder 'en chicken Moderator

    Joined:
    Dec 18, 2008
    Member:
    #11714
    Messages:
    49,855
    Gender:
    Male
    First Name:
    Ben
    Beech Creek
    Vehicle:
    05 Tundra SR5 (+250k AND COUNTING), 88 SR5 PU (SOLD), 98 TRD OR (CRUSHED)
    5100's all on fours
    I am more concerned about Mike f-ing with computers!!! Do they make jackstands for comps???
     
  9. Jan 28, 2010 at 9:23 AM
    #9
    mjp2

    mjp2 Living vicariously though myself Moderator

    Joined:
    Feb 16, 2007
    Member:
    #924
    Messages:
    17,773
    Gender:
    Male
    First Name:
    Milton Juevos Portimous II
    NJ
    Vehicle:
    '06 TRD Access Cab, v6, 6-speed
    Scaffolding and a painted grill
    C# is a strongly typed language. Could you include your variable declarations in the example?

     
  10. Jan 28, 2010 at 9:24 AM
    #10
    chris4x4

    chris4x4 With sufficient thrust, pigs fly just fine. Moderator

    Joined:
    May 8, 2008
    Member:
    #6497
    Messages:
    106,158
    Gender:
    Male
    First Name:
    FlimFlubberJAM
    Tenoe, AZ
    Vehicle:
    2013 Rubicon Unlimited,
    4.10 gears, sliders, and lots of buttons.
    Hmm.....Good point.
     
  11. Jan 28, 2010 at 9:25 AM
    #11
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand
    Here's the program file.

    PHP:
    /*
    * Adam Licht
    * Project2
    * CIS220 Section 2
    * 1/27/2010

    * This program takes values from textboxes, places them in to varibles and then in to new text boxes. 
    * It also keeps track of the count of inputs and the sum and average of the price.

    */
    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 
    Project2
    {
    public 
    partial class frmMain Form
    {
    //Define Data Members
    Int32 ID 0;
    String Description "";
    Double Price 0;
    Int32 Quantity 0;
    Int32 Count 0;
    Double Amount 0;
    Double Average 0;
    //end Data Members
     
     
    public frmMain()
    {
     
    InitializeComponent();
    }
    private 
    void frmMain_Load(object senderEventArgs e)
    {
    DateTime dtmCurrent DateTime.Today;
    lblDate.Text dtmCurrent.ToString("D");
    lblTitle.Text "Project Two";
    txtIDIn.Focus();
     
     
     
     
     
    }
    private 
    void btnExit_Click(object senderEventArgs e)
    {
    Application.Exit();
    }
    private 
    void btnAbout_Click(object senderEventArgs e)
    {
    MessageBox.Show("This is project 2. It does a little more than Project 1, yet the headache that came with programing it increased exponentally.","About");
     
    }
    private 
    void lblTitle_Click(object senderEventArgs e)
    {
    }
    private 
    void label1_Click(object senderEventArgs e)
    {
    }
    private 
    void lblDate_Click(object senderEventArgs e)
    {
     
     
     
    }
     
     
    private 
    void label2_Click(object senderEventArgs e)
    {
    }
    private 
    void btnGet_Click(object senderEventArgs e)
    {
    //txt to data members
    Int32 ID Convert.ToInt32(txtIDIn.Text);
    String Description txtDiscIn.Text;
    Double Price Convert.ToDouble(txtPriceIn.Text);
    Int32 Quantity Convert.ToInt32(txtQtyIn.Text);
    //end txt to data members
     
    //Counter
    Count Count 1;
    //end counter
     
    //Data Member to Output
     
    txtIDOut.Text ID.ToString();
    txtDiscOut.Text Description;
    txtPriceOut.Text Price.ToString();
    txtQtyOut.Text Quantity.ToString();
     
     
     
     
    //end Data member to Output
     
     
     
    }
    private 
    void btnClrIn_Click(object senderEventArgs e)
    {
    //Clear Inputs
    txtIDIn.Clear();
    txtDiscIn.Clear();
    txtPriceIn.Clear();
    txtQtyIn.Clear();
    //Reset Focus
    txtIDIn.Focus();
    }
    private 
    void btnClrOut_Click(object senderEventArgs e)
    {
    //Clear Outputs
    txtIDOut.Clear();
    txtDiscOut.Clear();
    txtPriceOut.Clear();
    txtQtyOut.Clear();
    //Reset Focus
    txtIDIn.Focus();
    }
    private 
    void btnDisp_Click(object senderEventArgs e)
    {
    //Calculate Amount
    Amount += Price;
     
     
    //Calculate Average
    Average = (Amount Count);
     
    //Display values
    txtCount.Text Count.ToString();
    txtAmt.Text Amount.ToString();
    txtAvg.Text Average.ToString();
    }
    private 
    void btnReset_Click(object senderEventArgs e)
    {
    //Clear Values
    txtCount.Clear();
    txtAmt.Clear();
    txtAvg.Clear();
     
    //Set values to 0
    Count 0;
    Amount 0;
    Average 0;
    }
    private 
    void txtCount_TextChanged(object senderEventArgs e)
    {
     
    }
    private 
    void txtAmt_TextChanged(object senderEventArgs e)
    {
    }
     
    }
    }
     
  12. Jan 28, 2010 at 9:29 AM
    #12
    jspadaro

    jspadaro Well-Known Member

    Joined:
    Jan 7, 2009
    Member:
    #12342
    Messages:
    2,994
    Gender:
    Male
    First Name:
    Jim
    Knoxville, TN
    Vehicle:
    Former Tacoma Owner
    Blue Oval Mod

    You're redefining Price. Don't redefine it. In btnGet_Click() just do Price = ...

    If you do Double Price = .... , price is local to that function.
     
  13. Jan 28, 2010 at 9:30 AM
    #13
    jspadaro

    jspadaro Well-Known Member

    Joined:
    Jan 7, 2009
    Member:
    #12342
    Messages:
    2,994
    Gender:
    Male
    First Name:
    Jim
    Knoxville, TN
    Vehicle:
    Former Tacoma Owner
    Blue Oval Mod
    And actually, btw, you're redefining all variables inside of btnGet_Click()

    If you define a variable in that function, you won't use the one that is global to your frmMain() class. you'll make new ones with that name that only hold value for the duration of that function call.

    So you're defining a new variable Price, setting THAT to the Price, and then in display, you're using the global Price, which never gets adjusted from 0.

    So you're also not going to see the correct id or any of the rest of that stuff you manipulate in btnGet_Click() ;)
     
  14. Jan 28, 2010 at 9:31 AM
    #14
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand

    That's it! Thanks a ton! Apreciate it.
     
  15. Jan 28, 2010 at 9:32 AM
    #15
    mjp2

    mjp2 Living vicariously though myself Moderator

    Joined:
    Feb 16, 2007
    Member:
    #924
    Messages:
    17,773
    Gender:
    Male
    First Name:
    Milton Juevos Portimous II
    NJ
    Vehicle:
    '06 TRD Access Cab, v6, 6-speed
    Scaffolding and a painted grill
    Saved me the trouble of thinking. :)
     
  16. Jan 28, 2010 at 9:32 AM
    #16
    Mondwa

    Mondwa Well-Known Member

    Joined:
    Dec 22, 2009
    Member:
    #28028
    Messages:
    1,365
    Gender:
    Male
    First Name:
    Michael
    Phoenix, AZ
    Vehicle:
    08 V6 Tacoma
    remote start, Allpro bumper, Slimchubby HID, MetalMiller custom Emblem
    :rofl:
     
  17. Jan 28, 2010 at 9:33 AM
    #17
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand

    So basically only use the prefixes (String, int, double) the first time when you define them globaly?
     
  18. Jan 28, 2010 at 10:32 AM
    #18
    mjp2

    mjp2 Living vicariously though myself Moderator

    Joined:
    Feb 16, 2007
    Member:
    #924
    Messages:
    17,773
    Gender:
    Male
    First Name:
    Milton Juevos Portimous II
    NJ
    Vehicle:
    '06 TRD Access Cab, v6, 6-speed
    Scaffolding and a painted grill
    Yes. Those prefixes are what define the variable types. When they appear in front of a variable, a new variable of that type is created within the current scope.

    If you're using an existing variable you just need to ensure that it's accessible within the current scope and refer to it by name.


    Some solid responses in this thread. Very cool. :)
     
  19. Jan 28, 2010 at 10:34 AM
    #19
    TacoNut

    TacoNut [OP] IgnoringChrisWatchingEdLi veVicariouslyThroughMJP2

    Joined:
    Mar 29, 2008
    Member:
    #5597
    Messages:
    5,243
    Gender:
    Male
    First Name:
    Adam
    Denver, Co
    Vehicle:
    16 TRD OR DCSB Quicksand

    Alright cool.


    Thanks everyone! Apreciate it!
     
  20. Jan 28, 2010 at 10:37 AM
    #20
    jspadaro

    jspadaro Well-Known Member

    Joined:
    Jan 7, 2009
    Member:
    #12342
    Messages:
    2,994
    Gender:
    Male
    First Name:
    Jim
    Knoxville, TN
    Vehicle:
    Former Tacoma Owner
    Blue Oval Mod
    Happy we could help
     
To Top