How to Create converter for C to F
and F to C.
1st Step: Create Converter Design.
Ø Drag a 2 label onto the form and
change the label TEXT in properties.
o
For
1st label change the TEXT into “Input Value :”
o
For
2nd label change the TEXT into “Result :”
Ø Drag a 1 textbox onto the form and change the
textbox NAME in properties.
o
For
textbox change the NAME into “mtxtValue”
Ø Drag a 2 RadioButtons onto the form
and change the RadioButtons NAME and TEXT in properties.
o
For
RadioButtons TEXT
§ For 1st RadioButtons Change the TEXT into “Fahrenheit to
Celsius”.
§ For 2nd RadioButtons Change the TEXT into “Celsius to
Fahrenheit”.
o
For
RadioButtons NAME
§ For 1st RadioButtons Change the NAME into “btnAdd”.
§ For 2nd RadioButtons Change the NAME into “btnSubtract”.
Ø Drag a 1 Button onto the form and
change the Button NAME and TEXT in properties.
o
For Button name change the NAME into “btnConvert”.
o
For
Button text change the TEXT into “Convert”.
Ø Drag a 2 label onto the form and
change the label TEXT and NAME in properties.
o
For label name change the NAME into “lblResult”
o
For
label text change the TEXT into “ ”
2nd Step: Start Coding.
Ø To Start Coding, double click the “CONVERT”
Button.
o
Code
for the CONVERT button.
Private Sub btnAdd_Click()Handles
btnAdd.Click
If
rbtnFahrenheittoCelsius.Checked = True Then
lblResult.Text = " Fahrenheit = " & mtxtValue.Text
& vbNewLine & " Celsius = "
& (mtxtValue.Text - 32) / 1.8
ElseIf
rbtnCelsiustoFahrenheit.Checked = True Then
lblResult.Text = " Celsius = " & mtxtValue.Text &
vbNewLine & " Fahrenheit = "
& (mtxtValue.Text * 1.8) + 32
End If
End Sub
3rd
Step: Run the Program.
Ø Click to start Debugging Button (F5).
Source Code:
Public Class Form1
Private Sub btnConvert_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles btnConvert.Click
If
rbtnFahrenheittoCelsius.Checked = True Then
lblResult.Text = " Fahrenheit = " & mtxtValue.Text
& vbNewLine & " Celsius = "
& (mtxtValue.Text - 32) / 1.8
ElseIf
rbtnCelsiustoFahrenheit.Checked = True Then
lblResult.Text = " Celsius = " & mtxtValue.Text &
vbNewLine & " Fahrenheit = "
& (mtxtValue.Text * 1.8) + 32
End If
End Sub
End Class
No comments:
Post a Comment