Connecting Tech Pros Worldwide Forums | Help | Site Map

celsius to fahrenheit

Newbie
 
Join Date: Apr 2009
Posts: 1
#1: Apr 14 '09
how to write a program in visual basic 2008 that displays a Celsius to Fahrenheit conversion table. Entries in the table should range from –40 to 40 degrees Celsius in increments of 5 degrees. Use the formula f = (9/5)*c + 32 to convert Celsius temperatures to Fahrenheit.

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#2: Apr 15 '09

re: celsius to fahrenheit


What you have tried so far ?

simply add two text boxes
accept value from one
after the calculation display on the other.
MrMancunian's Avatar
Expert
 
Join Date: Jul 2008
Location: Utrecht, The Netherlands
Posts: 283
#3: Apr 15 '09

re: celsius to fahrenheit


Quote:

Originally Posted by mattwhy50 View Post

how to write a program in visual basic 2008 that displays a Celsius to Fahrenheit conversion table. Entries in the table should range from –40 to 40 degrees Celsius in increments of 5 degrees. Use the formula f = (9/5)*c + 32 to convert Celsius temperatures to Fahrenheit.

This sounds like a school assignment to me, so I won't give you a full solution, but I think you should do something with a loop from -40 to 40 with a step 5, a datagridview with two columns and a function that converts the loopvalue to a fahrenheit value.

Good luck!

Steven
iam_clint's Avatar
Forum Leader
 
Join Date: Jul 2006
Location: Oklahoma
Posts: 1,076
#4: Apr 16 '09

re: celsius to fahrenheit


Even though this looks like a homework assignment some people learn out of example.
Expand|Select|Wrap|Line Numbers
  1.         For c = 0 To 20 Step 2 'makes a loop that starts at 0 and increments by 2 until it reaches 20
  2.             Dim Row As New DataGridViewRow 'declares a new row
  3.             Dim Cell As DataGridViewCell 'sets variable cell as a cell
  4.             Cell = New DataGridViewTextBoxCell() 'creates a new cell
  5.             Cell.Value = c 'sets the value of the cell
  6.             Row.Cells.Add(Cell) 'adds the cell to the row
  7.  
  8.             Cell = New DataGridViewTextBoxCell() 'creates a new cell
  9.             Cell.Value = (1.8 * c) + 32 'does the math (9/5) = (1.8 * c) + 32
  10.             Row.Cells.Add(Cell) 'adds the cell to the row
  11.             DataGridView1.Rows.Add(Row) 'adds the row to the datagridview
  12.         Next
  13.  

This will go from 0 to 20 in c and convert to f every 2 so 0 2 4 6 8 -> so on
You should be able to get a good start off of it.
Reply