Pages

Saturday 3 November 2012

Create a Position application in VB that changes the position of text in a label according to the command selected by the user. The application should include a Program menuwith an Exit command and a Position menu with TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, and BottomRight commands

Create a Position application in VB that changes the position of text in a label according to the command selected by the user. The application should include a Program menuwith an Exit command and a Position menu with TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, and BottomRight commands

Description:
In this post we are going to learn the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.

Open Microsoft visual studio
File-> New -> Project -> visual vb -> Windows Forms Application.

Program:

Design a window form as shown in figure in vb


Create a Position application in VB that changes the position of text in a label according to the command selected by the user. The application should include a Program menuwith an Exit command and a Position menu with TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, and BottomRight commands
Create a Position application in VB that changes the position of text in a label according to the command selected by the user. The application should include a Program menuwith an Exit command and a Position menu with TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, and BottomRight commands



Public Class Form1
    Private Sub TopCenterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TopCenterToolStripMenuItem.Click
        Label1.Location = New Point(0, 20)
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub TopCenterToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TopCenterToolStripMenuItem1.Click
        Label1.Location = New Point(125, 20)
    End Sub

    Private Sub TopRightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TopRightToolStripMenuItem.Click
        Label1.Location = New Point(250, 20)
    End Sub

    Private Sub MiddleLeftToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MiddleLeftToolStripMenuItem.Click
        Label1.Location = New Point(0, 125)
    End Sub

    Private Sub MiddlCenterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MiddlCenterToolStripMenuItem.Click
        Label1.Location = New Point(125, 125)
    End Sub

    Private Sub MiddleRightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MiddleRightToolStripMenuItem.Click
        Label1.Location = New Point(250, 125)
    End Sub

    Private Sub BottomTopToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomTopToolStripMenuItem.Click
        Label1.Location = New Point(0, 250)
    End Sub

    Private Sub BottomCenterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomCenterToolStripMenuItem.Click
        Label1.Location = New Point(125, 250)
    End Sub

    Private Sub BottomRightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BottomRightToolStripMenuItem.Click
        Label1.Location = New Point(250, 250)
    End Sub
End Class

Demo:

Create a Position application in VB that changes the position of text in a label according to the command selected by the user. The application should include a Program menuwith an Exit command and a Position menu with TopLeft, TopCenter, TopRight, MiddleLeft, MiddleCenter, MiddleRight, BottomLeft, BottomCenter, and BottomRight commands

Write a program in C# to implement Multiple Interfaces in a Single class.

Write a program in C# to implement Multiple Interfaces in a Single class.

Description:
In this post we are going to learn the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.

Open Microsoft visual studio
File-> New -> Project -> visual c#-> console Application.

Program:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace readwrite
{
    class Program
    {
        static void Main(string[] args)
        {
            Interfaces d = new Interfaces();
            Interfaces1 d1 = new Interfaces();
            Interfaces2 d2 = new Interfaces();
            d1.show1();
            d2.show2();
        }
    }
    interface Interfaces1
    {
        void show1();
    }
    interface Interfaces2
    {
        void show2();
    }

    class Interfaces : Interfaces1, Interfaces2
    {
        public void show1()
        {
            Console.WriteLine("This is Interface1.");
            Console.ReadLine();
        }
        public void show2()
        {
            Console.WriteLine("This is Interface2 ");
            Console.ReadLine();
        }
    }
}

Demo:
Write a program in C# to implement Multiple Interfaces in a Single class.
Write a program in C# to implement Multiple Interfaces in a Single class.

Sunday 14 October 2012

Create a VB.NET application displaying the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.

Create a VB.NET application displaying the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.

Description:
In this post we are going to learn the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.

Open Microsoft visual studio
File-> New -> Project -> visual vb -> Windows Forms Application.

Program:
Take 6 button on the top.
now drag and drop all five dialog OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog on the form it will automatically go to bellow as shown in figure.



Create a VB.NET application displaying the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.
Create a VB.NET application displaying the use of dialog control. Include all the five dialog controls like OpenFileDialog,SaveFileDialog,FolderBrowserDialog,FontDialog,ColorDialog.



take text field and PictureBox as shown in figure.

now double click on all button turn by turn and paste the code as shown in below. 


Public Class Form1

    Private Sub btnopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnopen.Click
        OpenFileDialog1.Title = "open"
        OpenFileDialog1.InitialDirectory = "D:\"
        If OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
        End If
    End Sub

    Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
        SaveFileDialog1.Title = "Save As"
        SaveFileDialog1.Filter = "TXT Files (*.txt*)|*.txt*"
        If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, TextBox1.Text, True)

        End If

    End Sub

    Private Sub btnbrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbrowse.Click
        FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer
        FolderBrowserDialog1.SelectedPath = "D:\"
        If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = FolderBrowserDialog1.SelectedPath
        End If
    End Sub

    Private Sub btnfont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfont.Click
        If FontDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
            TextBox1.Font = FontDialog1.Font
            TextBox1.ForeColor = FontDialog1.Color
        End If
    End Sub

    Private Sub btncolor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncolor.Click
        If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
            TextBox1.BackColor = ColorDialog1.Color
        End If
    End Sub

    Private Sub btnuser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnuser.Click
        Dim frm As Form2 = New Form2
        frm.TextBox1.Text = Me.TextBox1.Text
        frm.ShowDialog()
    End Sub
End Class


Write a program in asp.net C# to create read only properties & write only properties i.e public,private.

Write a program in  asp.net C# to create read only properties & write only properties i.e public,private.

Description:
In this post we are going to learn read only properties & write only properties i.e public,private. 

Open Microsoft visual studio
File-> New -> Project -> visual c#-> console Application

Program:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace readandwrite
{
    class Program
    {
        static void Main(string[] args)
        {
            select choice = new select();
            choice.name1 = "sizar";
            choice.age1 = 21;
            Console.WriteLine("My Name is: " + choice.name1);
            Console.WriteLine("My Age is:" + choice.age1);
            choice.age1++;
            Console.WriteLine("AGE is Incremented");
            Console.WriteLine("My Name is: " + choice.name1);
            Console.WriteLine("My Age is:" + choice.age1);
            Console.ReadLine();
        }
    }
}
public class select
{
    private String name;
    private int age;
    public String name1
    {
        get
        {
            return name;
        }
        set
        {
            name = value;
        }
    }

    public int age1
    {
        get
        {
            return age;
        }
        set
        {
            age = value;
        }

    }
}

Demo:


Write a program in  asp.net C# to create read only properties & write only properties i.e public,private.
Write a program in  asp.net C# to create read only properties & write only properties i.e public,private.






Write a C# program to demonstrate function overloading

Write a C# program to demonstrate function overloading

Description:
In this post we are going to learn function overloading.

Open Microsoft visual studio
File-> New -> Project -> visual c#-> console Application

Program:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _6.FunctionOverloading
{
    class Program
    {
        static void Main(string[] args)
        {
            shape s = new shape();
            s.area(5);
            s.area(5, 2);
        }
    }
    class shape
    {
        public void area(int a)
        {
            int c = a * a;
            Console.WriteLine("Square  area:{0}",c);
            Console.ReadLine();
        }

        public void area(int a,int b)
        {
            int d = a * b;
            Console.WriteLine("Rectangle area:{0}",d);
            Console.ReadLine();
        }
    }
}

Demo:

Write a C# program to demonstrate function overloading
Write a C# program to demonstrate function overloading




Write a C# program to print student details using constructor and destructor.

Write a C# program to print student details using constructor and destructor.

Description:
In this post we are going to learn constructor and destructor.

Open Microsoft visual studio
File-> New -> Project -> visual c#-> console Application

Program:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _5.Constructor
{
    class Program
    {
        static void Main(string[] args)
        {
            student s = new student("sizar",21);                                                                    
            Console.ReadKey();
   }
    }
    public class student
    {
        String name;
        int id;
        public student(String name, int id)
        {
            this.name = name;
            this.id = id;
            Console.WriteLine("\n Constructor Called..!\n");
            Console.WriteLine("Student Name:{0}",name);
            Console.WriteLine("Student id:{0}", id);
        }
        ~student()
        {
            Console.WriteLine("\nDestructor Called..!");
            Console.ReadLine();
        }
    }


Demo:
Write a C# program to print student details using constructor and destructor.
Write a C# program to print student details using constructor and destructor.
                              

Write a C# program to print student details using constructor and destructor.
Write a C# program to print student details using constructor and destructor.
                     



Download Code:

Saturday 13 October 2012

Design form to create calculator application in VB

Design form to create calculator application in VB

Description:

In this post we are going to learn how to make a calculator in vb 
Open Microsoft visual studio
File-> New -> Project -> visual vb ->  Windows Application

Program:

Design a window form as shown in figure in vb


Design form to create calculator application in VB
Design form to create calculator application in VB

now double click on 1 button. code file will open with this code.

Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
       
    End Sub

add code 

 txtans.Text = txtans.Text + "1"

 above " End Sub " as shown below do this for all button.


Imports System.Math
Public Class Form1
    Dim s As String
    Dim a As Double
    Dim x As Double
    Dim b As Double
    Dim c As Double
    Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
        txtans.Text = txtans.Text + "1"
    End Sub

    Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
        txtans.Text = txtans.Text + "2"
    End Sub

    Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
        txtans.Text = txtans.Text + "3"
    End Sub

    Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
        txtans.Text = txtans.Text + "4"
    End Sub

    Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
        txtans.Text = txtans.Text + "5"
    End Sub

    Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
        txtans.Text = txtans.Text + "6"
    End Sub

    Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
        txtans.Text = txtans.Text + "7"
    End Sub

    Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
        txtans.Text = txtans.Text + "8"
    End Sub

    Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
        txtans.Text = txtans.Text + "9"
    End Sub

    Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
        txtans.Text = txtans.Text + "0"
    End Sub

    Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
        a = Convert.ToDouble(txtans.Text)
        txtans.Text = ""
        x = 1
    End Sub

    Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsub.Click
        a = Convert.ToDouble(txtans.Text)
        txtans.Text = ""
        x = 2
    End Sub

    Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click
        a = Convert.ToDouble(txtans.Text)
        txtans.Text = ""
        x = 3
    End Sub

    Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
        a = Convert.ToDouble(txtans.Text)
        txtans.Text = ""
        x = 4
    End Sub

    Private Sub btneql_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneql.Click
        b = Convert.ToDouble(txtans.Text)
        txtans.Text = ""
        Select Case x
            Case 1
                c = a + b
                txtans.Text = c
            Case 2
                c = a - b
                txtans.Text = c
            Case 3
                c = a * b
                txtans.Text = c
            Case 4
                c = a / b
                txtans.Text = c
            Case 5
                c = a * a
                txtans.Text = c
            Case 6
                c = a
                txtans.Text = c
            Case Else
        End Select
    End Sub

    Private Sub btnsquare_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsquare.Click
        a = Convert.ToDouble(txtans.Text)
        x = 5
    End Sub

    Private Sub btbdot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btbdot.Click
        txtans.Text = txtans.Text + "."

    End Sub

    Private Sub btnsqrt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsqrt.Click
        a = Convert.ToDouble(txtans.Text)
        a = Sqrt(a)
        x = 6
    End Sub

    Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
        a = 0
        b = 0
        c = 0
        x = 0
        s = ""
        txtans.Text = ""
    End Sub

    
End Class

Demo:

Design form to create calculator application in VB
Design form to create calculator application in VB

Design form to create calculator application in VB
Design form to create calculator application in VB

Design form to create calculator application in VB
Design form to create calculator application in VB

Design form to create calculator application in VB
Design form to create calculator application in VB