This Blog is composed of how to create a program in Visual Studio.

How to create simple converter for Fahrenheit to celsius.


How to Create converter for C to F and F to C.

1st Step: Create Converter Design.



Ø  Drag a 2 label onto the form and change the label TEXT in properties.
o   For 1st  label change the TEXT into “Input Value :”
o   For 2nd label change the TEXT into “Result :”

Ø   Drag a 1 textbox onto the form and change the textbox NAME in properties.
o   For  textbox change the NAME into “mtxtValue”

Ø  Drag a 2 RadioButtons onto the form and change the RadioButtons NAME and TEXT in properties.
o   For RadioButtons TEXT 
§  For 1st RadioButtons Change the TEXT into “Fahrenheit to Celsius”.
§  For 2nd RadioButtons Change the TEXT into “Celsius to Fahrenheit”.

o   For RadioButtons NAME 
§  For 1st RadioButtons Change the NAME into “btnAdd”.
§  For 2nd RadioButtons Change the NAME into “btnSubtract”.

Ø  Drag a 1 Button onto the form and change the Button NAME and TEXT in properties.
o   For  Button name change the NAME into “btnConvert”.
o   For Button text change the TEXT into “Convert”.

Ø  Drag a 2 label onto the form and change the label TEXT and NAME in properties.
o   For  label name change the NAME into “lblResult”
o   For label text change the TEXT into “     ”

2nd Step: Start Coding.

Ø  To Start Coding, double click the “CONVERT” Button.

o   Code for the CONVERT button.

Private Sub btnAdd_Click()Handles btnAdd.Click
              If rbtnFahrenheittoCelsius.Checked = True Then
            lblResult.Text = " Fahrenheit = " & mtxtValue.Text & vbNewLine & " Celsius = " & (mtxtValue.Text - 32) / 1.8
        ElseIf rbtnCelsiustoFahrenheit.Checked = True Then
            lblResult.Text = " Celsius = " & mtxtValue.Text & vbNewLine & " Fahrenheit = " & (mtxtValue.Text * 1.8) + 32
        End If
End Sub





3rd Step: Run the Program.

Ø  Click to start Debugging Button (F5).






Source Code:

Public Class Form1

    Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
        If rbtnFahrenheittoCelsius.Checked = True Then
            lblResult.Text = " Fahrenheit = " & mtxtValue.Text & vbNewLine & " Celsius = " & (mtxtValue.Text - 32) / 1.8
        ElseIf rbtnCelsiustoFahrenheit.Checked = True Then
            lblResult.Text = " Celsius = " & mtxtValue.Text & vbNewLine & " Fahrenheit = " & (mtxtValue.Text * 1.8) + 32
        End If
    End Sub
End Class








Share:

How to Create Simple Log-In


How to Create Simple log-in

1st Step: Create a Log-in Design.



Ø  Drag a 2 label onto the form and change the label TEXT in properties.
o   For 1st  label change the TEXT into “User Name :”
o   For 2nd label change the TEXT into “Password :”

Ø  Drag a 2 textbox onto the form and change the textbox TEXT in properties.
o   For 1st  textbox change the TEXT into “txtUserName”
o   For 2nd textbox change the TEXT into “txtPassword”

Ø  Drag a 1 button onto the form and change the Button NAME and TEXT in properties.
o   For Button TEXT 
§  For 1st Button Change the TEXT into “Log-In”.

o   For Button NAME
§  For 1st Button Change the NAME into “btnLogIn”.

2nd Step: Start Coding

Ø  To Start Coding, double click the Form.

Ø  Declare the Variables.

o   Dim dgUserName,dgPassword  as String.            
§  dgUserName is a value entered in the First Textbox.
§  dgPassword  is a value entered in the Second Textbox.

Ø  Go back to design then double click button.

o   Code for the Log-In button.

Private Sub btnLogIn_Click()Handles btnLogIn.Click
                                                            If txtUserName.Text = "" Then
                                MsgBox("Please Input UserName!")
                        ElseIf txtPassword.Text = "" Then
                           MsgBox("Please Input Password!")
ElseIf txtUserName.Text = "User" And        txtPassword.Text = "user123" Then
                                MsgBox("Log-In Success!")
                                   txtUserName.Clear()
                                   txtPassword.Clear()
                          Else
                                 MsgBox("Invalid UserName or                                                            Password")
            End If
End Sub

3rd Step: Run the Program.

Ø  Click to start Debugging Button (F5).



Source Code:


Public Class Form1

    Private Sub btnLogIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogIn.Click
        If txtUserName.Text = "" Then
            MsgBox("Please Input UserName!")
        ElseIf txtPassword.Text = "" Then
            MsgBox("Please Input Password!")
        ElseIf txtUserName.Text = "User" And 
                    txtPassword.Text = "user123" 
        Then
            MsgBox("Log-In Success!")
            txtUserName.Clear()
            txtPassword.Clear()
        Else
            MsgBox("Invalid UserName or Password")
        End If
    End Sub
End Class









Share:

How to Create Simple Calculator


How to Create Simple Calculator

1st Step: Create Calculator Design.



Ø  Drag a 3 label onto the form and change the label TEXT in properties.
o   For 1st  label change the TEXT into “First Number :”
o   For 2nd label change the TEXT into “Second Number :”

o   For 3rd label change the TEXT into “Result :”

Ø  Drag a 3 textbox onto the form and change the textbox NAME in properties.
o   For 1st  textbox change the NAME into “txtFirstNumber”
o   For 2nd textbox  change the NAME into “txtSecondNumber”
o   For 3rd textbox  change the NAME into “txtResult”

Ø  Drag a 5 buttons onto the form and change the Button NAME and TEXT in properties.
o   For Button TEXT
§  For 1st Button Change the TEXT into “ADD”.
§  For 2nd Button Change the TEXT into “SUBTRACT”.
§  For 3rd Button Change the TEXT into “MULTIPLY”.
§  For 4th Button Change the TEXT into “DIVIDE”.
§  For 5th Button Change the TEXT into “CLEAR”.

o   For Button NAME
§  For 1st Button Change the NAME into “btnAdd”.
§  For 2nd Button Change the NAME into “btnSubtract”.
§  For 3rd Button Change the NAME into “btnMultiply”.
§  For 4th Button Change the NAME into “btnDivide”.
§  For 5th Button Change the NAME into “btnClear”.


2nd Step: Start Coding.

Ø  To Start Coding, double click the Form.
Ø  Declare the Variables.
o   Dim dgFirstNum,dgSecondNum,dgResult as double.                
§  dgFirstNum is a value entered in the "txtFirstNumber".
§  dgSecond  is a value entered in the "txtSecondNumber".
§  dgResult is the result.

Ø  Go back to design then double click ADD button.
o   Code for the ADD button.

Private Sub btnAdd_Click()Handles btnAdd.Click
          dgFirstNum = Val(txtFirstNumber.Text)
          dgSecondNum = Val(txtSecondNumber.Text)
    dgResult = dgFirstNum + dgSecondNum
End Sub

Ø  Go back to design then double click SUBTRACT button.
o   Code for the SUBTRACT button.

Private Sub btnSubtract_Click()Handles btnSubtract.Click
          dgFirstNum = Val(txtFirstNumber.Text)
          dgSecondNum = Val(txtSecondNumber.Text)
    dgResult = dgFirstNum - dgSecondNum
End Sub

Ø  Go back to design then double click MULTIPLY button.
o   Code for the MULTIPLY button.

Private Sub btnMultiply_Click()Handles btnMultiply.Click   
    dgFirstNum = Val(txtFirstNumber.Text)
          dgSecondNum = Val(txtSecondNumber.Text)
    dgResult = dgFirstNum * dgSecondNum
End Sub

Ø  Go back to design then double click DIVIDE button.
o   Code for the DIVIDE button.

Private Sub btnDivide_Click()Handles btnDivide.Click              
dgFirstNum = Val(txtFirstNumber.Text)
          dgSecondNum = Val(txtSecondNumber.Text)
    dgResult = dgFirstNum / dgSecondNum
End Sub

Ø  Go back to design then double click CLEAR button.
o   Code for the CLEAR button.

Private Sub btnClear_Click()Handles btnClear.Click   
    txtFirstNumber.Clear()
          txtSecondNumber.Clear()
txtResult.Clear()
End Sub

3rd Step: Run the Program.

Ø  Click to start Debugging Button (F5).





Source Code:

Public Class Form1
    Dim dgFirstNum, dgSecondNum, dgResult As Double
   
    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        dgFirstNum = Val(txtFirstNumber.Text)
        dgSecondNum = Val(txtSecondNumber.Text)
        dgResult = dgFirstNum + dgSecondNum
        txtResult.Text = dgResult
    End Sub

    Private Sub btnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click
        dgFirstNum = Val(txtFirstNumber.Text)
        dgSecondNum = Val(txtSecondNumber.Text)
        dgResult = dgFirstNum - dgSecondNum
        txtResult.Text = dgResult
    End Sub

    Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
        dgFirstNum = Val(txtFirstNumber.Text)
        dgSecondNum = Val(txtSecondNumber.Text)
        dgResult = dgFirstNum * dgSecondNum
        txtResult.Text = dgResult
    End Sub

    Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
        dgFirstNum = Val(txtFirstNumber.Text)
        dgSecondNum = Val(txtSecondNumber.Text)
        dgResult = dgFirstNum / dgSecondNum
        txtResult.Text = dgResult
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        txtFirstNumber.Clear()
        txtSecondNumber.Clear()
        txtResult.Clear()
    End Sub
End Class

Share:

About Me

My photo
Pagadian City, IX, Philippines

Followers

Social Profiles

Follow us

Keyboard

USB Drive

Total Pageviews