In this posting I will tell you a simple VB programming tips "How to convert degree / temperature from Celcius to another one", so the base temperature is Celcius. The temperature will be converted into Fahrenheit, Rheamur and Kelvin. As we know that we have three conversion formulas are (in Celcius base):
Fahrenheit = ( Celcius X 1.8 ) + 32
Rheamur = Celcius X 0.8
Kelvin = Celcius + 273.15
How to apply these three formulas in simple VB6 programming? It's just an easy thing to do! You can do it just with a simple VB program. Please follow below instructions for your tips!
So your screen design will look like below image:
Now, let's write the program coding.
Double click any where in Form1 area to create a Sub Form_Load()
Write down below program coding in the Sub Form_Load() area
'to clear text boxes text Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = ""
Double click Command1 command button to create a Sub Command1_Click()
Write down below program coding in the Sub Command1_Click() area
Text2.Text = Val(Text1.Text) * 1.8 + 32 Text3.Text = Val(Text1.Text) * 0.8 Text4.Text = Val(Text1.Text) + 273.15
So your program will look like the following list:
Private Sub Command1_Click() Text2.Text = Val(Text1.Text) * 1.8 + 32 Text3.Text = Val(Text1.Text) * 0.8 Text4.Text = Val(Text1.Text) + 273.15 End Sub
Private Sub Form_Load() 'to clear text boxes text Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" End Sub
Now, you can test your program by clicking Start button on your VB toolbar to check whether your program is correct or not.
If the results are 59 in Text2 (Fahrenheit), 12 in Text3 (Rheamur), and 288.15 in Text4 (Kelvin), it means that your program is correct and running properly.
Look at below image for your illustration.
How do you think, it's an easy simple VB programming tips isn't it?
1 comments:
nice inpo gan . .
:-D
Post a Comment