Post: My first ever program [C#]
04-29-2011, 03:51 AM #1
Blackstorm
Veni. Vidi. Vici.
(adsbygoogle = window.adsbygoogle || []).push({}); Here's my first ever program for C#. I made it the same day I BARELY started C#.

I think I did good! I know this sounds weird but I got most of my experience from MW2 GSC scripting.. Even though C# differs every now and then vastly with functions, etc. from MW2 GSC.

Well, I'm uploading my whole source, I created a basic calculator.

Tell me what you think, what I can improve, and how I did on it! =D

Constructional criticism IS accepted. Here's my main code:

    
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
int i;
string textStr1, textStr2;
string val = "abcdefghijklmnopqrstuvwxyz/*+=!@#$%^&(){}][';><,";
textStr1 = textBox1.Text;
textStr2 = textBox2.Text;
bool invalidVal;
invalidVal = false;
if (textStr1.Length == 0) invalidVal = true;
if (textStr2.Length == 0) invalidVal = true;
for (i = 0; i < textStr1.Length; i++)
{
foreach (char ch in val)
{
if (textStr1[i] == Char.ToLower(ch))
{
invalidVal = true;
break;
}
}
}
for (i = 0; i < textStr2.Length; i++)
{
foreach (char ch in val)
{
if (textStr2[i] == Char.ToLower(ch))
{
invalidVal = true;
break;
}
}
}
if (invalidVal == false)
{
progressBar1.Maximum = 100000;
progressBar1.Minimum = 0;
progressBar1.Value = 0;
while (progressBar1.Value < progressBar1.Maximum) progressBar1.Value += 10;
float a = Convert.ToSingle(textBox1.Text);
float b = Convert.ToSingle(textBox2.Text);
if (comboBox1.SelectedItem == "+") textBox3.Text = Convert.ToString(a + b);
else if (comboBox1.SelectedItem == "-") textBox3.Text = Convert.ToString(a - b);
else if (comboBox1.SelectedItem == "/") textBox3.Text = Convert.ToString(a / b);
else if (comboBox1.SelectedItem == "*") textBox3.Text = Convert.ToString(a * b);
else if (comboBox1.SelectedItem == "^")
{
float num = a;
for (int x = 1; x < b; x++) num = num * a;
textBox3.Text = Convert.ToString(num);
}
string textStr3 = textBox3.Text;
}
else if (invalidVal == true) System.Windows.Forms.MessageBox.Show("Invalid Characters, or blank spaces have been inputted.");
}

private void redToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Red;
}

private void purpleToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Purple;
}

private void yellowToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Yellow;
}

private void orangeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.BackColor = System.Drawing.Color.Orange;
}
}
}


Here's my source if you wanna see the actual program! The UPDATED program was built in bin\Release.

Enjoy! =D

Source Code: You must login or register to view this content.

Actual Program (*.exe): You must login or register to view this content.

Virus scan: You must login or register to view this content.

The following 4 users say thank you to Blackstorm for this useful post:

helpmeoprah, Kakashii, kiwimoosical, Sigma
04-30-2011, 06:05 AM #11
Blackstorm
Veni. Vidi. Vici.
Originally posted by d7w7z View Post
C# FTW Smile

I just started making a new program like 10 minutes ago, trying to make it with a dynamic treeview and dynamic system tray icon so I can add/remove reminders and shortcuts to other folders and .exe's Winky Winky


Sounds kewl! =D
05-02-2011, 02:30 AM #12
Kakashii
Can’t trickshot me!
Maybe you could help train me with C++ coding :] or C#...or .bat ... or java ....any code works.. Smile

The following user thanked Kakashii for this useful post:

Relevant
05-08-2011, 10:13 AM #13
Merkii
Former Staff
wow this is great for a first program keep it up bro :y:.
05-10-2011, 06:33 PM #14
Kombust
At least I can fight
Don't know where to compile/edit C# but I gave it a thorough read through and it looks well constructed, and I noticed them colours Winky Winky
05-10-2011, 08:39 PM #15
Rath
Today Will Be Different
Nice, you finally got on the C# train :p... and dude your program sucks so bad that I had to use it to do my homework last night :carling:

:y:

The following user thanked Rath for this useful post:

Blackstorm
05-20-2011, 05:30 AM #16
I Know the perfect thing for ya.. You must login or register to view this content... find all his tutorials there.
05-20-2011, 03:29 PM #17
Josh_ox3
Treasure hunter
Originally posted by Bark. View Post
Don't know where to compile/edit C# but I gave it a thorough read through and it looks well constructed, and I noticed them colours Winky Winky


Use "Visual Studio 2010 Express", C# is a good language i like it.
05-20-2011, 03:46 PM #18
djamp789.
Can’t trickshot me!
nice im taking this class next year then ap computer programming
05-20-2011, 05:51 PM #19
C# IDE: SharpDevelop
C++ IDE: Code::Blocks

C# is a good language =D

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo