Solved

What is wrong with my code

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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 …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 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