Solved

What is wrong with my code

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now