Thats the lesson thing I need to do. I already created the gui (using visual C# 2008) I just dont know how I add this code routine.
Code: Select all
public bool IsNumeric(string s)
{
try
{
Double.Parse(s);
}
catch
{
return(false);
}
return(true);
}
Moderator: Coders of Rage
Code: Select all
public bool IsNumeric(string s)
{
try
{
Double.Parse(s);
}
catch
{
return(false);
}
return(true);
}
Code: Select all
class
{
method
{
// do stuff
}
method
{
// do stuff
}
}
Code: Select all
if(IsNumeric(TextBox1.Text) == true)
{
// your temp convert code goes here
}
else
{
// your message window code goes here
}
Code: Select all
((temp_c/(5/9))+32);
Should be:Levio91 wrote:Thanks LeonBlade.
I have another problem though I cant figure out whats wrong with my equation thats supposed to be used to convert celsius to fahrenheit!!!!!! could you look at it and tell me whats wrong this is the equation.
Code: Select all
((temp_c/(5/9))+32);
Code: Select all
((temp_c*(9/5))+32);
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Code: Select all
((temp_c / (5.0 / 9.0)) + 32);
Code: Select all
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;
//*********************************************************
// Convert:: A simple conversion example
// Levi Harman A.K.A. (mth)
// ********************************************************
// Date Comments pgr
// ===== ========= ====
// 2/10/09 First working version with input tests mth
//*********************************************************
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
float temp_c;
float temp_f;
InitializeComponent();
}
public bool IsNumeric(string s)
{
try
{
Double.Parse(s);
}
catch
{
return (false);
}
return (true);
}
// f2c
private void button1_Click(object sender, EventArgs e)
{
float temp_f = 0;
float temp_c = 0;
if (IsNumeric(textBox1.Text) == true)
{
// temp convert code goes here
temp_f = float.Parse(textBox1.Text);
temp_c = (float) ((temp_f - 32) * 5 / 9.0);
textBox2.Text = temp_c.ToString();
}
else
{
// message window code goes here
textBox1.Text = "need number";
}
}
// c2f
private void button2_Click(object sender, EventArgs e)
{
float temp_f = 0;
float temp_c = 0;
if (IsNumeric(textBox2.Text) == true)// validity test
{
temp_c = float.Parse(textBox2.Text);
temp_f = (float)((temp_c / (5.0 / 9.0)) + 32);
textBox1.Text = Convert.ToString(temp_f);
}
else
{
textBox2.Text = "need a number";
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
You said you are using Microsoft Visual C#? I am using the Microsoft Visual Studio 2008 so it should look alike (I guess), here is how I do it... (I believe it doesnt have this feature in the express edition though):Levio91 wrote:
Now all I need to know is how to make this file an exe like when I install games and stuff...
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.