How to Convert Degree from Rheamur to Another in VB 6 Programming?

Thursday, September 3, 2009 ·

In the previous posting you have learnt a simple VB programming tips "How to convert degree from Fahrenheit into another one in VB6 programming". Now we will learn another simple VB programming tips "How to convert degree / temperature from Rheamur into another one", so the base degree is Rheamur, and will be converted into Celcius, Fahrenheit and Kelvin. We have three previous conversion formulas (Celcius base) as follow:
Fahrenheit = ( Celcius X 1.8 ) + 32
Rheamur = Celcius X 0.8
Kelvin = Celcius + 273.15


From these formulas, now we can generate new three other formulas (Rheamur base) as the following:
Celcius = Rheamur / 0.8
Fahrenheit = ( ( Rheamur / 0.8 ) X 1.8 ) + 32
Kelvin = ( Rheamur / 0.8 ) + 273.15


Now, let's implement above formulas into a simple VB6 programming. Let's go on to the following simple VB programming tips!

  • Create a VB project for example Project1
  • Create a VB standard form for example Form1
  • Create 5 labels for example Label1, Label2, Label3, Label4, Label5
  • Go to Label1 properties by clicking Label1 object, and then change Label1 Caption into "Degree Conversion", and change Font Size into 14.
  • Go to Label2 properties, and then change Label2 Caption into "Rheamur"
  • Go to Label3 properties, and then change Label3 Caption into "Celcius"
  • Go to Label4 properties, and then change Label4 Caption into "Fahrenheit"
  • Go to Label5 properties, and then change Label5 Caption into "Kelvin"
  • Create 4 text boxes for example Text1, Text2, Text3, Text4
  • Create a command button for example Command1
  • Go to Command1 properties, and change Command1 caption into "Convert"

    So your screen design should look like below image:
    Screen Design Simple VB6 Program - Degree Conversion from Rheamur

  • Double click anywhere in the Form1 area to create a Sub Form_Load()
  • Write down below program coding in the Sub Form_Load() area
    'to clear the content of text boxes
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""

  • Double click the command button with caption "Convert" to create a Sub Command1_Click()
  • Write down below program coding in the Sub Command1_Click() area
    'conversion process
    'Text1 represents Rheamur
    'Text2 represents Celcius
    'Text3 represents Fahrenheit
    'Text4 represents Kelvin
    Text2.Text = Val(Text1.Text) / 0.8
    Text3.Text = ((Val(Text1.Text) / 0.8) * 1.8) + 32
    Text4.Text = (Val(Text1.Text) / 0.8) + 273.15

    So your program will look like below listing:
    Private Sub Command1_Click()
    'conversion process
    'Text1 represents Rheamur
    'Text2 represents Celcius
    'Text3 represents Fahrenheit
    'Text4 represents Kelvin
    Text2.Text = Val(Text1.Text) / 0.8
    Text3.Text = ((Val(Text1.Text) / 0.8) * 1.8) + 32
    Text4.Text = (Val(Text1.Text) / 0.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

    Ok, your program's finish. Test your program by clicking Start button on your VB toolbar to know whether your program working properly or not.
  • Type a number in Text1 for example 80 (in the text box with label "Rheamur")
  • Click command button with label "Convert"
    If the results are 100 in Text2 (Celcius), 212 in Text3 (Fahrenheit), and 373.15 in Text4 (Kelvin), it means that your program is correct and working properly.
    Look at below image for your illustration.
    Simple Vb Program Degree Conversion From Rheamur

    It is very easy and very simple isn't it? Would you like to try it? Ok, in the next posting I'll write another simple tips with VB6 programming. See you in the next posting!




  • 0 comments:

    Post a Comment