?
Solved

What is wrong with my code

Posted on 2006-11-18
4
Medium Priority
?
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 48

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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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 …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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