locked
Double to string in visual studio 2010?

    Pertanyaan

  • Conversion from string "lblWeight" to type 'Integer' is not valid.  I tried it as Cdbl, Cdec Cint All which didn't not work

    any suggestions?

    thanks Delmer

    Dim lblBMITotal As Integer = 1
            Dim lblBMRTotal As Integer = 1
            Dim years As Integer = 1             ' year
            Dim years1 As Integer = 1              ' year
            Dim Weight As Integer = 1            ' pound 0r 0.45359 kilo
            Dim inches1 As Integer = 1            ' inch  
            Dim kilograms2 As Integer = 1             ' kilogram or 2.2 pounds
            Dim meters As Integer = 1                   ' meter or 39 inches



            lblYears.Text = years.ToString
            lblYears1.Text = years1.ToString
            lblWeight.Text = Weight.ToString
            lblInches1.Text = inches1.ToString
            lblKilograms2.Text = kilograms2.ToString
            lblMeters.Text = meters.ToString
            lblBMITotal = lblBMITotal.ToString("n1")
            lblBMRTotal = lblBMRTotal.ToString("n1")

            Try
                If radWomen.Checked = True Then

                    lblWeight.Text = InputBox("What is your weight?", "lbs")
                    lblInches1.Text = InputBox("what is your height?", "Inches")
                    lblKilograms2.Text = InputBox(" How much do you wieght?", "Kilograms")
                    lblMeters.Text = InputBox("What is your height?", "Meters/ centimeters")
                    ' Womens body mass Index standard.
                    lblBMRTotal = CInt("lblweight" * 703) / ("lblInches1^2")
                    'Womens body Mass INDEX Metric.
                    lblBMRTotal = CInt("lblKilograms2") / CInt("lblMeters^2")
                End If
            Catch ex As Exception

                If radWomen.Checked = True Then
                    lblYears.Text = InputBox("What is your Age", "", "years")
                    lblWeight.Text = InputBox("What is your weight?", "lbs")
                    lblInches1.Text = InputBox("what is your height?", "Inches")
                    lblYears1.Text = InputBox("What is your Age?", "Years")
                    lblKilograms2.Text = InputBox(" How much do you wieght?", "Kilograms")
                    lblMeters.Text = InputBox("What is your height?", "Meters/ centimeters")

                    ' Basel Metabolic rate standard for women

                    lblBMRTotal = 655 + CInt("lblWeight") + CInt("lblinches1") - CInt("lblYears1")
                    'Basel Metabolic rate metric for Women.
                    lblBMRTotal = 655 + (9.6 * "lblKilograms2") + (1.8 * "lblmeters") - (4.7 * "lblyears")
                End If
                If Double.TryParse(lblBMITotal, lblBMRTotal) Then
                    MessageBox.Show("Success!")
                Else
                    MessageBox.Show("Error: Enter a Whole Number")

                End If
            End Try

    09 Maret 2012 1:06