Beginner project help
using System.Drawing.Text;
using System.Runtime.CompilerServices;
namespace KBlair_Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnCalc_Click(object sender, EventArgs e)
{
String txtInput = Console.ReadLine();
}
private void txtmAI_TextChanged(object sender, EventArgs e)
{
}
private void txtInputValue_TextChanged(object sender, EventArgs e)
{
//txtOutputValue.Text = txtInputValue.Text; //string outputValue = (string)txtInputValue.Text; //Output value of psig = ((mAI(this is the input value) - 4) / 16) * 12 + 3; // mA conversion to psig //outputValue = ((txtInputValue -4 ) / 16 ) * 12 + 3; //txtOutputValue.Text = outputValue; } private void btnClear_Click(object sender, EventArgs e) { txtInputValue.Text = ""; txtOutputValue.Text = ""; txtmAI.Text = ""; MessageBox.Show("All fields have been cleared!"); } private void txtOutputValue_TextChanged(object sender, EventArgs e) { } } }
//txtOutputValue.Text = txtInputValue.Text; //string outputValue = (string)txtInputValue.Text; //Output value of psig = ((mAI(this is the input value) - 4) / 16) * 12 + 3; // mA conversion to psig //outputValue = ((txtInputValue -4 ) / 16 ) * 12 + 3; //txtOutputValue.Text = outputValue; } private void btnClear_Click(object sender, EventArgs e) { txtInputValue.Text = ""; txtOutputValue.Text = ""; txtmAI.Text = ""; MessageBox.Show("All fields have been cleared!"); } private void txtOutputValue_TextChanged(object sender, EventArgs e) { } } }
24 Replies
this should get you going in the right direction.
okay max, im in VC-0 trying to get help
streaming
Ok, now I'm done with my stuff for now.
In the properties window there is a bunch of event options that let you set the method called when something happens, brief look, It looks like you want to look for the
TextChanged eventyou could do this on TextChanged but I think starting out I think doing the simpler thing and doing the calculation when the button is clicked is probably better.
yeh, I glanced over the doc, you have to have a calc button so do like Max said
probs should have read through it thoroughly first aye
Yeah i just dont know hwo to get calc to work
Did the professor explain things like events, event handler functions, functions, binding, variables?
If not that’s a major fail on his part
And you can’t do this
Given that there is a Calculate button I would imagine any processing needs to happen on the click of it
That
txtOutputValue_TextChanged will likely never get fired as that textbox looks disabledmaxmahem
this should get you going in the right direction.
Quoted by
<@82228151555457024> from #Beginner project help (click here)
React with ❌ to remove this embed.
Was there any requirements for input validation?
Some professors take off points for going the extra mile
Yes it’s dumb, but I’ve seen it happen
I would make as many assumptions as possible with data and let it hard fail
I can't imagine they would fault you for using
TryParse over Parse but whose to say. Little point in learning the wrong way to do it though.True but your implementation would do nothing if they enter in a non parseable value
What if the professor wants it to fail if it can’t parse?
fail how. Crash? That's stupid behavior.
Yes
Crash
I'd tell the professor that was stupid.
I forget if WinForms has some validation routines you can build in here. I think WPF does.
Unlike work assignments, school assignments are usually graded on your ability to follow directions as is
It depends on the professor of course
But all I’m saying I’ve seen them knock off points for making it do what you made it do
Because a crash is a more obvious indicator that it’s failed vs appearing not to do anything and not telling the user why
If you’re not going to have it do anything, you better be showing validation messages
I mean you could throw in a
MessageBox.Show on the fail path if you want I guess.
It obviously wasn't meant to be a complete sollution, just something to get them started.He said it was super easy and we should add flair to it and the progress bar was for a curveball when we dont even know the basics
its utter shit
No he didnt explain ANY of that
That’s so dumb
This is not a judgement on you, but it sounds like you don’t know the fundamentals of programming, let alone WinForms
This is a week 2 assignment?
this is week 2
And i dont know the fundamentals at all we never discussed them
he even said to skip the book
im not joking when I say we went from, getting the console to ask for a name and say your name is this or a birthday, then going into winforms
+formulas and etc.
What’s the class?
C#
like the basic one
ITSE1330
I can’t speak for others here, but when I went to school for computer science, we were taught the basics. I can say that you’re getting shafted. As a professional dev who’s trained juniors, your professor’s curriculum is shit.
Sorry to hear that, but we aren’t geared towards doing your assignments for you and even just giving you a basic hint isn’t going to work without some significant learning on your part
This assignment was doomed to fail
But who knows, people can learn under pressure
Just my 2c
Hey I appreciate it man, I felt really discouraged looking at this thinking I wasn't capable of programming, but if its a matter of wrong curriculum that gives me hope and let's me know that I CAN do this if I apply myself elsewhere.
I dont want to put this off on anyone as if it's their problen. I was desperate and thought maybe there's someone who really loves teaching who can help someone eager to learn is all.
I'm still going to throw everything I can at it, it's the only programming class for my degree but I want to excell and plan on learning more after so IM GONNA DO IT.