13 Replies - 17105 Views - Last Post: 02 February 2007 - 07:47 PM Rate Topic: -----

#1 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Temperature Converter

Posted 01 February 2007 - 02:49 PM

I am trying to create a program which converts temperature

Centigrade to Fahrenheit and back again.

There has to be two functions. I want one for centigrade and one for Fahrenheit.

Conversions

F C subtract 32, multiply by 5 then divide by 9

C F multiply by 9, divide by 5 then add 32

I have got a

enter temperature text box
then a group box with to radio buttons to selected both conversions
also a convert button
and this will be displayed in a label

Can anyone please start me off on this and help

Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Temperature Converter

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Temperature Converter

Posted 01 February 2007 - 07:44 PM

The site has a policy by which we prefer to see a good faith effort on the part of users before providing source code in the matter of academic assignments. Can you post what you've written so far? Our members would be more than happy to provide some guidance.

Thanks!
Was This Post Helpful? 0
  • +
  • -

#3 eXceed69  Icon User is offline

  • "Super Sentai Knight Of DawN"
  • member icon

Reputation: 7
  • View blog
  • Posts: 688
  • Joined: 12-November 06

Re: Temperature Converter

Posted 01 February 2007 - 08:04 PM

Yes, you had to give some effort. :P
If you want search from the snippet/s related to your concern then just got some idea to those, that could start you on for this work. :D
Was This Post Helpful? 0
  • +
  • -

#4 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Re: Temperature Converter

Posted 02 February 2007 - 07:21 AM

this is what i have but its not at all right

Public Class DrivingTest4

	Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click

		Dim Temperature As Integer
		Dim centigrade As Integer
		Dim fahenheit As Integer
		Dim answer As Integer

		Me.txtTemperature.Text = Temperature
		Me.rdoCentigrade.Checked = centigrade
		Me.rdoFahrenheit.Checked = fahenheit

		Me.txtTemperature.Text = Temperature
		Temperature = answer
		lblAnswer.Text = answer

		If rdoFahrenheit.Checked = True Then
			Temperature = Temperature - 32 * 5 / 9
		Else
			MessageBox.Show("Select An Option")
		End If

	End Sub

	Function centigrade(ByVal input As Integer) As Integer

		Dim result As Integer
		Dim answer As String

		result = ((input - 32) * 5) / 9
		answer = result & "Centigrade"

		answer = result & "Centigrade"

		Return answer

	End Function

	Function fahenheit(ByVal input As Integer) As Integer

		Dim result As Integer
		Dim answer As String

		result = ((input - 32) * 5) / 9
		answer = result & "fahenheit"

		answer = result & "fahenheit"

		Return answer

	End Function

End Class


Was This Post Helpful? 0
  • +
  • -

#5 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

Re: Temperature Converter

Posted 02 February 2007 - 01:43 PM

One way i would do it is just this
Dim ConversionF As Integer
dim ConversionC As Integer
Dim Celsius as Boolean
Dim Farinhite As Boolean
Dim Result As Integer
Dim X = 0
Dim Y = 0
Private Sub Convert ()
If Celsius = True Then
Result = Textbox1.Text - 32 * 5 / 9
MsgBox(Result)
End If
If Farinhite = True Then
Result = Texbox1.Text * 9 / 5 + 32
Msgbox(Result)
End If
End Sub
Private sub Button1_click(ByVal sender.Obeject, ByVal e Ass sytem.EventArgs) Handles Button1.Click
Convert()
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As system.object, ByVal e As System.EventArgs) Handles RadioButton1.Check Changed ' This Should Be on the same line as the other one
x = x + 1
If Int(X / 2) = X / 2 Then ' This is basicly saying if it is even
Celsius = True
Else
Celsius = False
End If
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As system.object, ByVal e As System.EventArgs) Handles RadioButton2.Check Changed ' This Should Be on the same line as the other one
Y = Y + 1
If Int(Y / 2) = Y / 2 Then ' This is basicly saying if it is even
Farinhite = True
Else
Farinhite = False
End If
End Sub


This shoule clear it up o by the way exuse my spelling of F and C
o by the way on the form you should have a textbox named textbox1 a radiobutton meaning you put a C deggree in that is named radio button1 and a second radiobutton called radiobutton2 that means F deggrees is in the the textbox
hope that clears it up
John
Was This Post Helpful? 0
  • +
  • -

#6 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Re: Temperature Converter

Posted 02 February 2007 - 01:49 PM

does this include 2 functions?
Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Temperature Converter

Posted 02 February 2007 - 02:26 PM

Do you see two functions? ;)
Was This Post Helpful? 0
  • +
  • -

#8 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Re: Temperature Converter

Posted 02 February 2007 - 02:29 PM

well i thought you had to include something like

Function centigrade(ByVal input As Integer) As Integer

end function

or i am wrong i dont know
Was This Post Helpful? 0
  • +
  • -

#9 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

Re: Temperature Converter

Posted 02 February 2007 - 02:52 PM

View PostINeedHelpPlease, on 2 Feb, 2007 - 02:29 PM, said:

well i thought you had to include something like

Function centigrade(ByVal input As Integer) As Integer

end function

or i am wrong i dont know

You Could Use a function i just like to use subs better then use event handelers to produce a product
but you coudl use a funcion
Was This Post Helpful? 0
  • +
  • -

#10 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Re: Temperature Converter

Posted 02 February 2007 - 03:03 PM

im afraid i need to have two function what would i change in the coding to get them
Was This Post Helpful? 0
  • +
  • -

#11 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Temperature Converter

Posted 02 February 2007 - 03:08 PM

You can change the sub to a function...give it a try! :)

http://www.morrowlan...ction/index.php
http://www.suite101....ual_basic/64058
Was This Post Helpful? 0
  • +
  • -

#12 INeedHelpPlease  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 25-January 07

Re: Temperature Converter

Posted 02 February 2007 - 03:14 PM

could you edit the code you entered cos im unsure what bits to get rid of sorry
Was This Post Helpful? 0
  • +
  • -

#13 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Temperature Converter

Posted 02 February 2007 - 03:16 PM

Actually, it's not my code...I was trying to encourage you to attempt to make the modification yourself - that is how one learns.

The author may well return and make the modifications for you.

Have a great night.
Was This Post Helpful? 0
  • +
  • -

#14 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

Re: Temperature Converter

Posted 02 February 2007 - 07:47 PM

i think you could do a function but u need some subs to use it. like This
Dim Result
Private Function ConvertToF ()
Result = Textbox1.Text -  ' Put formula here
Msgbox(result)
end Function
Private Function ConvertToC ()
Result = Textbox1.Text - ' put formula here
msgbox(result)
End Function
Private sub Textox1.textchanged(ByVal sender As System.Object, ByBal e As System.EventArgs) Handles Textbox1.Text 
If F = True Then 
ConverttoC ()
End If 
If C = True then 
ConverttoF()
End If
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As system.object, ByVal e As System.EventArgs) Handles RadioButton1.Check Changed
C = True
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As system.object, ByVal e As System.EventArgs) Handles RadioButton2.Check Changed
F = True
End Sub


hope this helps
john
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1