Guys
In this post we will discuss another funny as well as interesting program in Visual Basic i.e, making temperature scale with Scroll Bar where both the Fahrenheit and Celsius will change at a same time .
Scroll bar control is vary good tools for the programmers of Visual basic.It is vary essay to use,It is of two form horizontal and vertical.We can place it in form according to our needs or choices.
We have done our design in such a way
We took four labels only and a scroll option.Changed Property
Label1:
caption :Fahrenheit
Label2:
caption: Celsius
HScroll1:
maximum:100
minimum:0
Problem Statement:
Write a program in Vb to convert Fahrenheit and Celsius at a same time using scroll bar.
Source Code:
Private Sub Vscroll1_Change( ) Dim C as Integer Dim F as Integer Label1.Caption = VScroll1.Value C = Val(Label1.Caption) F = 9/5*C + 32 Label2.Caption = F End Sub
- The source code is written under Change event of VScroll.
- Dim is used to declared a variable.
- Val function is used to change a string to numeric.
Thanks for reading this post.Hope this will help you.
If you have any doubt comment bellow , we will be happy to help you.
No comments:
Post a Comment