Solved

What is wrong with my code

Posted on 2006-11-18
4
182 Views
Last Modified: 2011-09-20
I am trying to convert English Distance to metric Distances.

I created two text boxes and an Accept Button. I want to input the English measurments in one box and having it output in Metric from the other text box. What am i doing wrong? can some one help me solve this?

Public Class Form1

    Private Sub Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accept.Click
        Dim MtrcOutput As Double
        Dim Miles As Double
        Dim Kilometers As Double
        Miles = 3.5
        Kilometers = Miles * 1.6

        MtrcOutput = CDbl(EngInput.Text) * Kilometers

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
0
Comment
Question by:TAMSCODAN
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17972806
   Private Sub Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accept.Click
        Dim MtrcOutput As Double
        Dim Miles As Double
        Dim Kilometers As Double
        Miles = 3.5
        Kilometers = Miles * 1.6

        MtrcOutput.Text = (CDbl(EngInput.Text) * Kilometers).ToString()

    End Sub
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 17972847
Perhaps this will help....

    Private Sub Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accept.Click

        MtrcOutput.Text = CDbl(EngInput.Text) * 1.6

    End Sub

This assumes the Imperial measurement TextBox is called EngInput and the Metric Output TextBox is called MtrcOutput.

Regards,

Wayne
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 17972873
you have to see what the names for the 2 textboxes are. you can see that directly in the designer, click on the textboxes and see the property Name. remember them, and modify the following code with those names. i am using name "textbox1" for English input, and "textbox2" for Metric output.

Private Sub Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Accept.Click
'notice i removed the line: Dim MtrOutput as Double
        Dim Miles As Double
        Dim Kilometers As Double
        Miles = Convert.ToDouble(TextBox1.Text)
        Kilometers = Miles * 1.6

        TextBox2.Text = Kilometers.ToString()

End Sub
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question