-1

Well. Still gettin' used to it.

I need to create a program that converts temperatures and such for school. I have:

  • Celsius
  • Kelvin
  • Reamour
  • And Fahrenheit

Basically when I write to textbox, like I input 4 Celsius and my program must display and convert that 4 Celsius to all the other's

I need help with very basic formula thing. Not the strongest at math but can you help me out?

txtkelvin.Text = FormatNumber(Val(txtcelsius.Text)5.0 / 9.0 * -32)

I get an error at this line. Probably missing some ')' Out from somewhere but where?

And where should I find the other formulas for the temperatures? Kelvin and others?

MPelletier
  • 16,256
  • 15
  • 86
  • 137

2 Answers2

2

You're missing a multiplication operator:

Val(txtcelsius.Text)5.0 

Should be:

Val(txtcelsius.Text) * 5.0 

That being said, your formula is not entirely correct. You most likely want:

txtkelvin.Text = FormatNumber(Val(txtcelsius.Text) + 273.15) ' celsius to kelvin

Or:

txtkelvin.Text = FormatNumber(((Val(txtFahrenheit .Text) - 32) * 5.0 / 9.0) + 273.15) ' fahrenheit to kelvin
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
0

You could use the TypedUnits library -> http://www.codeproject.com/Articles/611731/Working-with-Units-and-Amounts

That library contains all the necessary to manage/convert units (as Celsius).

An example:

     Dim Conversion As TypedUnits.Amount = _
         TypedUnits.UnitManager.ConvertTo(New TypedUnits.Amount( _
                                          2, _
                                          StandardUnits.TimeUnits.Minute), _
                                          StandardUnits.TimeUnits.Second)

     MsgBox(Conversion.Value & " Seconds")  Result: 120 Seconds


     Dim unit As TypedUnits.Amount = _
         New TypedUnits.Amount(1, StandardUnits.LengthUnits.KiloMeter)

     MsgBox(unit.Unit.Factor)  Result: 1000
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417