In the previous posting I've told you a simple VB programming tips "How to convert degree from Celcius into another one". In this posting I'll tell you a tips "How to convert degree from Fahrenheit into another one", so the base degree is Fahrenheit. It will be converted into Celcius, Rheamur and Kelvin. As we know that we have three previous conversion formulas (Celcius base): 'to clear the content of text boxes
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'conversion process
'Text1 represents Fahrenheit
'Text2 represents Celcius
'Text3 represents Rheamur
'Text4 represents Kelvin
Text2.Text = (Val(Text1.Text) - 32) / 1.8
Text3.Text = ((Val(Text1.Text) - 32) / 1.8) * 0.8
Text4.Text = ((Val(Text1.Text) - 32) / 1.8) + 273.15
Private Sub Command1_Click()
'conversion process
'Text1 represents Fahrenheit
'Text2 represents Celcius
'Text3 represents Rheamur
'Text4 represents Kelvin
Text2.Text = (Val(Text1.Text) - 32) / 1.8
Text3.Text = ((Val(Text1.Text) - 32) / 1.8) * 0.8
Text4.Text = ((Val(Text1.Text) - 32) / 1.8) + 273.15
End Sub Private Sub Form_Load()
'to clear the content of text boxes
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Fahrenheit = ( Celcius X 1.8 ) + 32
Rheamur = Celcius X 0.8
Kelvin = Celcius + 273.15
From above formulas, we are able to generate three other formulas (Fahrenheit base) as below:
Celcius = ( Fahrenheit - 32 ) / 1.8
Rheamur = ( ( Fahrenheit - 32 ) / 1.8 ) X 0.8
Kelvin = ( ( Fahrenheit - 32 ) / 1.8 ) + 273.15
Now let's implement these formulas in VB6 simple programming. Please follow below steps for your tips!
So your design will look like below image (just a simple Screen Design):
Double click any where in Form1 area to create a Sub Form_Load()
Write down below program coding in the Sub Form_Load() area
Double click Command1 command button (with caption "Convert") to create a Sub Command1_Click()
Write down below program coding in the Sub Command1_Click() area
So your program should look like below listing:
Note: In this simple VB program we haven't used variables yet, but we just use controls from Toolbox. Mybe in the next program we will use variables.
Ok, your program finish. Test your program by clicking Start button on your VB toolbar to know whether your program's working properly or not.
If the results are 100 in Text2 (Celcius), 80 in Text3 (Rheamur), and 373.15 in Text4 (Kelvin), it means that your program is correct and working properly.
Look at below image for your illustration. Your program should like it.
It's an easy simple VB program isn't it? Would you like to try it?
Sunday, August 16, 2009
How to Convert Degree from Fahrenheit to Another in VB6 Programming?
Labels:
VB6 Sample Program
0 comments:
Post a Comment