Want to port my celc to fahr conv from c# to visual basic
Posted: Wed Feb 18, 2009 2:26 am
How do I do this? I mainly want to do this so I can figure out visual basic. (dont worry I already have the guis)
visual basic code so far
entire c# code
visual basic code so far
Code: Select all
Public Class Form1
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
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)
{
}
}
}