Mits Mits2013

download Mits Mits2013

of 27

Transcript of Mits Mits2013

  • 7/27/2019 Mits Mits2013

    1/27

    Q. 1Design an application for addition , subtraction , multiplication and

    division of two number.

    1. Code for the subtract command (Command2). The code will be asfollows:

    Private Sub Command2_Click()a = Val(Text1.Text)

    b = Val(Text2.Text)

    r = a - b

    Text3.Text = r

    End Sub

    Code for the multiply command (Command3). The code will be as follows:

    Private Sub Command3_Click()a = Val(Text1.Text)

    b = Val(Text2.Text)

    r = a * b

    Text3.Text = r

    End Sub

    Code for the divide command (Command4). The coding will be as follows:

    Private Sub Command4_Click()a = Val(Text1.Text)

    b = Val(Text2.Text)

    r = a / b

    Text3.Text = r

    End Sub

    Start the coding for the add command (Command1). The code will be as

    follows:

    Private Sub Command1_Click()a = Val(Text1.Text)

    b = Val(Text2.Text)

  • 7/27/2019 Mits Mits2013

    2/27

    r = a + b

    Text3.Text = r

    End Sub

  • 7/27/2019 Mits Mits2013

    3/27

    Out put

  • 7/27/2019 Mits Mits2013

    4/27

    02 Design An Application For display factorial of a number , input by the

    user .

    Private sub command1 _ click ( )

    Dim a , I, f As Double

    i=1

    f=1

    a=val(text1.text)

    while i

  • 7/27/2019 Mits Mits2013

    5/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    6/27

    Q.3 design an application for displaying Fibonacci series

    Private Sub Command1_Click()

    Dim x, g, n, i, sum As Integer

    n = Val(Text1.Text)

    x = 0

    y = 1

    Print x

    Print y

    For i = 3 To n

    sum = x + y

    Print sum

    x = y

    y = sum

    y = sum

    Next i

    End Sub

  • 7/27/2019 Mits Mits2013

    7/27

    Out put

  • 7/27/2019 Mits Mits2013

    8/27

    Q.4 Design An Application For Displaying For A Calculator

    Dim Op1, Op2 As Double

    Dim Opr As String

    Private Sub Command1_Click()

    Text1.Text = Text1.Text + Command1.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command2_Click()

    Text1.Text = Text1.Text + Command2.CaptionIf cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command3_Click()

    Text1.Text = Text1.Text + Command3.CaptionIf cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command4_Click()

    Text1.Text = Text1.Text + Command4.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

  • 7/27/2019 Mits Mits2013

    9/27

    Private Sub Command5_Click()

    Text1.Text = Text1.Text + Command5.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = FalseEnd If

    End Sub

    Private Sub Command6_Click()

    Text1.Text = Text1.Text + Command6.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command7_Click()

    Text1.Text = Text1.Text + Command7.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command8_Click()

    Text1.Text = Text1.Text + Command8.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command9_Click()

    Text1.Text = Text1.Text + Command9.Caption

    If cleardisplay Then

  • 7/27/2019 Mits Mits2013

    10/27

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub Command10_Click()

    Text1.Text = Text1.Text + Command10.Caption

    If cleardisplay Then

    Text1.Text = ""

    cleardisplay = False

    End If

    End Sub

    Private Sub CommandDot_Click()

    If InStr(Text1.Text, ".") Then

    Exit Sub

    Else

    Text1.Text = Text1.Text + "."

    End If

    End Sub

    Private Sub Commandcls_Click()

    Text1.Text = ""

    End Sub

    Private Sub CommandPlus_Click()

    Op1 = Val(Text1.Text)

    Opr = "+"

    Text1.Text = ""

    End Sub

    Private Sub CommandMinus_Click()

    Op1 = Val(Text1.Text)

    Opr = "-"Text1.Text = ""

    End Sub

    Private Sub CommandMul_Click()

    Op1 = Val(Text1.Text)

    Opr = "*"

  • 7/27/2019 Mits Mits2013

    11/27

    Text1.Text = ""

    End Sub

    Private Sub CommandDiv_Click()

    Op1 = Val(Text1.Text)Opr = "/"

    Text1.Text = ""

    End Sub

    Private Sub CommandEqu_Click()

    Op2 = Val(Text1.Text)

    Select Case Opr

    Case "+": Text1.Text = Op1 + Op2

    Case "*": Text1.Text = Op1 * Op2

    Case "-": Text1.Text = Op1 - Op2

    Case "/": Text1.Text = Op1 / Op2

    End Select

    End Sub

    Private Sub Commandexit_Click()

    End

    End Sub

    Private Sub Form_Load()Text1.Text = ""

    End Sub

  • 7/27/2019 Mits Mits2013

    12/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    13/27

    Q. 5 Design an application for displaying even numbers from 1 to 50.

    dim a(50) as integer

    dim i as integer

    dim n as integer

    private sub command_click()

    for i 1 to 50

    Next i

    a(i) = inputbox ("enter any no.""no.""0")

    Next i

    for i = 1 to 50print a(i)

    n=n/i

    if n mod 2 = 0 then

    Next i

    end if

    msgbox "even numbe"&even

    end if

  • 7/27/2019 Mits Mits2013

    14/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    15/27

    Q.6 Design An Application For Counting Even And Odd Numbers.

    using System;

    using System.Collections.Generic;using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Linq;

    using System.Text;

    using System.Windows.Forms;

    namespace Odd_and_even_numbers

    {

    public partial class Form1 : Form{

    public Form1()

    {

    InitializeComponent();

    }

    private void button1_Click(object sender, EventArgs e)

    {

    try{

    listBox1.Items.Clear();

    int limit = Convert.ToInt32(textBox1.Text);

    for (int i = 1; i

  • 7/27/2019 Mits Mits2013

    16/27

    try

    {

    listBox1.Items.Clear();

    int limit = Convert.ToInt32(textBox1.Text);

    for (int i = 2; i

  • 7/27/2019 Mits Mits2013

    17/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    18/27

    Q. 8Design an application for converting fahrenheit to Celsius and vice versa

    Imports System.Web

    Imports System.Web.Services

    Imports System.Web.Services.Protocols

    _

    _

    _

    Public Class Service

    Inherits System.Web.Services.WebService

    _

    Public Function HelloWorld() As String

    Return "Hello World"

    End Function

    Public Function FahrenheitToCelsius(ByVal Fahrenheit As

    String) As String

    Dim fahr

    fahr = Trim(Replace(Fahrenheit, ",", "."))

    If fahr = "" Or IsNumeric(fahr) = False Then Return "Error"

    Return ((((fahr) - 32) / 9) * 5)

    End Function

    Public Function CelsiusToFahrenheit(ByVal Celsius As

    String) As String

    Dim cel

    cel = Trim(Replace(Celsius, ",", "."))

    If cel = "" Or IsNumeric(cel) = False Then Return "Error"

  • 7/27/2019 Mits Mits2013

    19/27

    form target="_blank" action="Service.asmx/FahrenheitToCelsius"

    method="POST">

    Fahrenheit to Celsius:

    Celsius to Fahrenheit:

  • 7/27/2019 Mits Mits2013

    20/27

  • 7/27/2019 Mits Mits2013

    21/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    22/27

    Q.9 Design an application for fill registration form and display

    Private Shared kLibraryKey As String =

    "3F76246B3B0E194506CBC8F512D70B9D0EF8242CEFA92E03237D7152AF

    70DBD428ED559FBB90"

    ' The register state of the application which is computed when the form is

    loaded

    Private registered As Boolean

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles MyBase.Load

    Try

    Dim Proc As Process = Process.GetCurrentProcess()

    ' This call will display the trial dialogs if needed

    Dim ret = InitTrial(kLibraryKey, Proc.MainWindowHandle)

    ' 0 return code means that the application is registered using a valid code,

    otherwise is in trial

    If ret = 0 Then

    registered = True

    End If

    Catch ex As Exception

    MessageBox.Show(ex.ToString())

    Process.GetCurrentProcess().Kill()

    End Try

    End Sub

    Private Sub DoRegister()

    Try

    Dim Proc As Process = Process.GetCurrentProcess()

  • 7/27/2019 Mits Mits2013

    23/27

    Dim ret = DisplayRegistration(kLibraryKey, Proc.MainWindowHandle)

    ' 0 return code means that the application was already registered or it

    ' has just been registered, otherwise is in trial

    If ret = 0 Then

    registered = True

    End If

    Catch ex As Exception

    MessageBox.Show(ex.ToString())

    Close()

    End Try

    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As

    System.Object, ByVal e As System.EventArgs) Handles

    AboutToolStripMenuItem.Click

    Dim dlg As AboutBox1 = New AboutBox1

    ' Set the about box member to the registered state computed when the

    application loaded

    dlg.registered = Me.registered

    ' Display the About box

    dlg.Show()

    End Sub

    Private Sub RegisterToolStripMenuItem_Click(ByVal sender As

    System.Object, ByVal e As System.EventArgs) Handles

    RegisterToolStripMenuItem.ClickIf registered Then

    MessageBox.Show("The application is already registered.", "Registered",

    MessageBoxButtons.OK, MessageBoxIcon.Information)

    Else

    DoRegister()

  • 7/27/2019 Mits Mits2013

    24/27

    End If

    End Sub

    Into the AboutBox1.vb source file add the following code snippets:

    ...

    Public registered As Boolean

    Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As

    System.EventArgs) Handles MyBase.Load

    ...

    If Me.registered Then

    Me.TextBoxDescription.Text = "registered - thank you"Else

    Me.TextBoxDescription.Text = "trial"

    End If

    End Sub

  • 7/27/2019 Mits Mits2013

    25/27

    OUT PUT

  • 7/27/2019 Mits Mits2013

    26/27

    INDEX

    S.NO. PROGRAMS

    1 Design an application for addition , subtraction , multiplication and

    division of two numbers.

    2 Design an application for display factorial of a number, input by the

    user.

    3 Design an application for displaying Fibonacci series.

    4 Design an application for a calculator.

    5 Design an application for despising even numbers from 1 to 50.

    6 Design an application for counting even odd numbers.

    7 Design an application for checking user id and password in maximum

    three attempts.

    8 Design an application for converting Fahrenheit to Celsius and vice

    versa .

    9 Design an application for fill registration from display

    10 Design an application that displays shapes as per the commands

    selected on its menu . the menu displayed on the application should beas .

  • 7/27/2019 Mits Mits2013

    27/27

    PRACTICAL FILE

    ON

    VISUAL BASIC

    SUBMITTED TO :- SUBMITTED BY :-

    ASST. PROF NEHA BHARDWAJ KAVITA

    ASST. PROF. GYANU GUPTA 2ND

    YEAR 3RD

    SEM

    (CIVIL )