Want to port my celc to fahr conv from c# to visual basic

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Levio91
Chaos Rift Regular
Chaos Rift Regular
Posts: 119
Joined: Thu Nov 06, 2008 9:50 pm

Want to port my celc to fahr conv from c# to visual basic

Post by Levio91 »

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

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
entire c# code

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)
            {

            }
        }
    }
"Criticism is something you can avoid easily by saying nothing, doing nothing, and being nothing. " - Aristotle

http://www.facebook.com/profile.php?id= ... ef=profile
Image
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Want to port my celc to fahr conv from c# to visual basic

Post by MarauderIIC »

You do it by rewriting everything yourself, I'm not going to do it for you (and neither will most people here). More than happy to help you with a particular problem. However, "entire code" with "how do i port this" yields "rewrite it yourself."
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: Want to port my celc to fahr conv from c# to visual basic

Post by programmerinprogress »

Using properties on a form, and binding the properties and variables together(or rather assigning variables to certain properties of a window's controls) is pretty standard stuff you know.

Why don't you try figuring it out yourself before constantly posting "how do I do it" threads?

I would start with using a controls(prefferably a button) click event which:
- takes the values from text boxes (or another type of control)
- sticks them in variables
- does some arithmetic to work out the conversion
-dumps the answer back to a text box

That would be the way to think about how to do it, but i'm not writing any code out, it's your project...
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
Post Reply