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

Wednesday, July 29, 2009 · 0 comments

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):
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!

  • 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 "Fahrenheit"
  • Go to Label3 properties, and then change Label3 Caption into "Celcius"
  • Go to Label4 properties, and then change Label4 Caption into "Rheamur"
  • 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 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

    'to clear the content of text boxes
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""


    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

    '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


    So your program should look like below listing:

    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


    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.
  • Type a number in Text1 for example 212 (in the text box with label "Fahrenheit")
  • Click command button with label "Convert"
    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.
    A Simple VB Program Degree Conversion from Fahrenheit

    It's an easy simple VB program isn't it? Would you like to try it?


  • Table of Contents

    Saturday, July 25, 2009 · 5 comments




    1. Stop Dreaming Start Action
    2. How to Start Using VB 6 Programming?
    3. How to Save Your VB Program?
    4. What's Visual Basic Development Environment ?
    5. 8 Basic Steps to Create Program in Visual Basic
    6. Visual Basic Toolbox
    7. Form Designer Window in Visual Basic
    8. Visual Basic Properties Window
    9. Project Explorer Window in Visual Basic
    10. Visual Basic Code Editor Window
    11. Visual Basic Standard Toolbar
    12. With..End With Statement to Set Object Properties in VB6
    13. How to Copy an Image or Picture to Clipboard in VB 6 Programming?
    14. How to Convert Numbers into Letters in VB 6 Programming?
    15. How to Automate Conversion Numbers into Letters in VB 6 Programming?
    16. How to Convert Degree from Celcius to Another in VB 6 Programming?
    17. How to Convert Degree from Fahrenheit to Another in VB 6 Programming?
    18. How to Convert Degree from Rheamur to Another in VB 6 Programming?
    19. How to Convert Degree from Kelvin to Another in VB 6 Programming?
    20. Temperature Conversion with Multiple Base in VB6 Programming?
    21. If..Then..Else..End If VB6 Sample Program 1


    How to Automate Conversion Numbers into Letters in VB 6 Programming?

    Wednesday, July 22, 2009 · 0 comments

    How to automate conversion numbers? In the previous posting you have learnt how to convert numbers into letters with Select Case..End Select control structure, If..Then..Else..End If control structure, and command button. The conversion will be processed after you clik command button. In this session you still learn how to convert number into letter with Select Case..End Select and If..Then..Else..End If, however you don't need a command button anymore. The conversion will automatically processed when you typing a number in the text box. How to do this? What's the program like?

    This is just an easy thing to do. You can use the previous program conversion number you have created. You just write down your coding in Sub Text1_Change() and Sub Text2_Change(). This two Subs that make conversion process automatically done. For detail how to do, you can follow below instructions (it's a simple VB programming tips).

    1. Using if..then..else..end if control structure

  • Create a VB project for example Project1
  • Create a VB standard form for example Form1
  • Create a text box for example Text1
  • Create another text box for example Text2
  • Create a label for example Label1
  • Create another label for example Label2
  • Doubleclick Text1 text box to create a Sub Text1_Change()
  • Write down below program coding in the Sub Text1_Change() area

    If Val(Text1.Text) = 0 Then
    Label1.Caption = "zero"
    Else
    If Val(Text1.Text) = 1 Then
    Label1.Caption = "one"
    Else
    If Val(Text1.Text) = 2 Then
    Label1.Caption = "two"
    Else
    If Val(Text1.Text) = 3 Then
    Label1.Caption = "three"
    Else
    If Val(Text1.Text) = 4 Then
    Label1.Caption = "four"
    Else
    If Val(Text1.Text) = 5 Then
    Label1.Caption = "five"
    Else
    If Val(Text1.Text) = 6 Then
    Label1.Caption = "six"
    Else
    If Val(Text1.Text) = 7 Then
    Label1.Caption = "seven"
    Else
    If Val(Text1.Text) = 8 Then
    Label1.Caption = "eight"
    Else
    If Val(Text1.Text) = 9 Then
    Label1.Caption = "nine"
    Else
    If Val(Text1.Text) = 10 Then
    Label1.Caption = "ten"
    Else
    If Val(Text1.Text) = 11 Then
    Label1.Caption = "eleven"
    Else
    If Val(Text1.Text) = 12 Then
    Label1.Caption = "twelve"
    Else
    If Val(Text1.Text) = 13 Then
    Label1.Caption = "thirteen"
    Else
    If Val(Text1.Text) = 14 Then
    Label1.Caption = "forteen"
    Else
    If Val(Text1.Text) = 15 Then
    Label1.Caption = "fifteen"
    Else
    If Val(Text1.Text) = 16 Then
    Label1.Caption = "sixteen"
    Else
    If Val(Text1.Text) = 17 Then
    Label1.Caption = "seventeen"
    Else
    If Val(Text1.Text) = 18 Then
    Label1.Caption = "eighteen"
    Else
    If Val(Text1.Text) = 19 Then
    Label1.Caption = "nineteen"
    Else
    If Val(Text1.Text) = 20 Then
    Label1.Caption = "twenty"
    Else
    Label1.Caption = "unrecognize number"
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If



  • 2. Using Select Case..End Select control structure

  • Doubleclick Text2 text box to create a Sub Text2_Change()
  • Write down below program coding in the Sub Text2_Change() area

    Select Case Val(Text2.Text)
    Case 0
    Label2.Caption = "zero"
    Case 1
    Label2.Caption = "one"
    Case 2
    Label2.Caption = "two"
    Case 3
    Label2.Caption = "three"
    Case 4
    Label2.Caption = "four"
    Case 5
    Label2.Caption = "five"
    Case 6
    Label2.Caption = "six"
    Case 7
    Label2.Caption = "seven"
    Case 8
    Label2.Caption = "eight"
    Case 9
    Label2.Caption = "nine"
    Case 10
    Label2.Caption = "ten"
    Case 11
    Label2.Caption = "eleven"
    Case 12
    Label2.Caption = "twelve"
    Case 13
    Label2.Caption = "thirteen"
    Case 14
    Label2.Caption = "forteen"
    Case 15
    Label2.Caption = "fifteen"
    Case 16
    Label2.Caption = "sixteen"
    Case 17
    Label2.Caption = "seventeen"
    Case 18
    Label2.Caption = "eighteen"
    Case 19
    Label2.Caption = "nineteen"
    Case 20
    Label2.Caption = "twenty"
    Case Else
    Label2.Caption = "unrecognize number"
    End Select



  • You can run your program by clicking Start button on your VB toolbar to check whether your program is correct or not.
  • Type a number in Text1 box for example 15
  • Type a number in Text2 box for example 15

    If letter "fifteen" appears in both Label1 and Label2, it means that your program is correct, and running properly.





  • How to Convert Numbers into Letters in VB 6 Programming?

    Wednesday, July 15, 2009 · 4 comments

    In this posting I will tell you a simple VB programming tips how to convert numbers from 0 until 20 into letters. To the application you can use either If..Then..Else...End If or Select Case..End Select control structure. In this application just demonstrate how to use both control structures. What is the simple program like? Please look at below simple VB programming tips.

    1. Using If..Then..Else..End If control structure

  • Create a VB project for example Project1
  • Create a VB standard form for example Form1
  • Create a command button for example Command1
  • Create another command button for example Command2
  • Create a text box for example Text1
  • Create another text box for example Text2
  • Create a label for example Label1
  • Create another label for example Label2
  • Doubleclick Command1 commandbutton to create a Sub Command1_Click()
  • Write down below simple VB program coding in the Sub Command1_Click() area

    If Val(Text1.Text) = 0 Then
    Label1.Caption = "zero"
    Else
    If Val(Text1.Text) = 1 Then
    Label1.Caption = "one"
    Else
    If Val(Text1.Text) = 2 Then
    Label1.Caption = "two"
    Else
    If Val(Text1.Text) = 3 Then
    Label1.Caption = "three"
    Else
    If Val(Text1.Text) = 4 Then
    Label1.Caption = "four"
    Else
    If Val(Text1.Text) = 5 Then
    Label1.Caption = "five"
    Else
    If Val(Text1.Text) = 6 Then
    Label1.Caption = "six"
    Else
    If Val(Text1.Text) = 7 Then
    Label1.Caption = "seven"
    Else
    If Val(Text1.Text) = 8 Then
    Label1.Caption = "eight"
    Else
    If Val(Text1.Text) = 9 Then
    Label1.Caption = "nine"
    Else
    If Val(Text1.Text) = 10 Then
    Label1.Caption = "ten"
    Else
    If Val(Text1.Text) = 11 Then
    Label1.Caption = "eleven"
    Else
    If Val(Text1.Text) = 12 Then
    Label1.Caption = "twelve"
    Else
    If Val(Text1.Text) = 13 Then
    Label1.Caption = "thirteen"
    Else
    If Val(Text1.Text) = 14 Then
    Label1.Caption = "forteen"
    Else
    If Val(Text1.Text) = 15 Then
    Label1.Caption = "fifteen"
    Else
    If Val(Text1.Text) = 16 Then
    Label1.Caption = "sixteen"
    Else
    If Val(Text1.Text) = 17 Then
    Label1.Caption = "seventeen"
    Else
    If Val(Text1.Text) = 18 Then
    Label1.Caption = "eighteen"
    Else
    If Val(Text1.Text) = 19 Then
    Label1.Caption = "nineteen"
    Else
    If Val(Text1.Text) = 20 Then
    Label1.Caption = "twenty"
    Else
    Label1.Caption = "unrecognize number"
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If
    End If


    2. Using select case...end select control structure
  • Doubleclick Command2 command button to create a Sub Command2_Click()
  • Write down below program coding in the Sub Command2_Click() area

    Select Case Val(Text2.Text)
    Case 0
    Label2.Caption = "zero"
    Case 1
    Label2.Caption = "one"
    Case 2
    Label2.Caption = "two"
    Case 3
    Label2.Caption = "three"
    Case 4
    Label2.Caption = "four"
    Case 5
    Label2.Caption = "five"
    Case 6
    Label2.Caption = "six"
    Case 7
    Label2.Caption = "seven"
    Case 8
    Label2.Caption = "eight"
    Case 9
    Label2.Caption = "nine"
    Case 10
    Label2.Caption = "ten"
    Case 11
    Label2.Caption = "eleven"
    Case 12
    Label2.Caption = "twelve"
    Case 13
    Label2.Caption = "thirteen"
    Case 14
    Label2.Caption = "forteen"
    Case 15
    Label2.Caption = "fifteen"
    Case 16
    Label2.Caption = "sixteen"
    Case 17
    Label2.Caption = "seventeen"
    Case 18
    Label2.Caption = "eighteen"
    Case 19
    Label2.Caption = "nineteen"
    Case 20
    Label2.Caption = "twenty"
    Case Else
    Label2.Caption = "unrecognize number"
    End Select


    You can run your program by clicking Start button on your VB toolbar to check whether your program is correct or not.
  • Type a number in Text1 box for example 15
  • Click Command1 commandbutton
  • Type a number in Text2 box for example 15
  • Click Command2 commandbutton
    If letter "fifteen" appears in both Label1 and Label2, it means that your program is correct, and running properly.

    Look at below screen shot for your illustration.
    Sample a Simple VB6 Program Conversion Number to Letter

    What do you think about it? It is an easy simple VB programming tips isn't it? Would you like to try?



  • How to Copy Image or Picture to Clipboard in VB 6 Programming?

    Saturday, July 11, 2009 · 2 comments

    In many VB program applications display images. And maybe you want to copy the image and paste into other office program like MS Excel, MS Word, etc. To do this thing in VB6 programming, please follow below steps of simple VB programming tips:
    First, you should have a picture that will be loaded by the program. For example you have a picture or image file named Adenium.jpg, and you save your picture in a folder with name D:\MyPicture

  • Open your Microsoft VB6 program
  • Create a VB project for example Project1
  • Create a standard form for example Form1
  • Create an image object from the toolbox for example Image1
  • Create a command button for example Command1
    Please look at below screen shot for your illustration.

    How to Copy Image to Clipboard VB Program
  • Double click any where in Form1 area to create a Sub Form_Load()
  • And then type below program coding in the Sub Form_Load() area

    'Load picture into image box
    Image1.Picture = LoadPicture("D:\MyPicture\Adenium.JPG")


  • Double_click Command1 button to create a Sub Command1_Click()
  • Write down below program coding in Sub Command1_Click() area

    'Clear clipboard first
    Clipboard.Clear
    'Load the picture from Image1 into Clipboard
    Clipboard.SetData Image1.Picture


  • So your program will look like the following list:

    Private Sub Command1_Click()
    'Clear clipboard first
    Clipboard.Clear
    'Load the picture from Image1 into Clipboard
    Clipboard.SetData Image1.Picture
    End Sub
    Private Sub Form_Load()
    'Load picture into image box
    Image1.Picture = LoadPicture("D:\MyPicture\Adenium.JPG")
    End Sub


    Please look at below screen shot for your illustration.
    How to Copy Image to Clipboard VB program



    To check whether your program works or not:

  • Click Start panel on your VB design screen
    If your Image appears on your screen it means that your Sub Form_Load() is working.
    How to Copy Image to Clipboard VB Program


  • Click Command1 command button to copy your image into clipboard
  • Open an Office Program like MS Excel
  • Place your pointer in one of MS Excel cell (for example place in cell A1)
  • Right_Click, then click Paste
    If your picture appears on your MS Excel sheet it means that your program is working properly.

  • How to Copy Image to Clipboard VB Program

    How to Copy Image to Clipboard VB Program

    It's just a very easy thing to do, isn't it?