Solved

What is wrong with my code

Posted on 2006-11-18
4
183 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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

808 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