Solved

# What is wrong with my code

Posted on 2006-11-18
Medium Priority
188 Views
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
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

LVL 143

Expert Comment

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

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

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

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
Course of the Month12 days, 10 hours left to enroll