Showing posts with label form. Show all posts
Showing posts with label form. Show all posts

Thursday, 29 May 2014

program 13: restaurant menu

program to create restaurant menu using listbox and calculate total item and price

-----------------------------------------code---------------------------------------------------------

Public Class Form1
    Dim v, b, n, m, s As Integer
    Dim total As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
        ListBox2.Items.Add(ListBox1.SelectedItem)
        TextBox1.Text = ListBox2.Items.Count()
    End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ListBox2.Items.Remove(ListBox2.SelectedItem)
        TextBox1.Text = ListBox2.Items.Count()
    End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim a, i, j As Integer
        j = 0
        a = ListBox2.Items.Count
        For i = 0 To a
            If (i < a) Then
                If ListBox2.Items(i) = "Vadapav(Rs.10)" Then
                    j = j + 10
                End If
                If ListBox2.Items(i) = "Barger(Rs.15)" Then
                    j = j + 15
                End If
                If ListBox2.Items(i) = "Noodles(Rs.35)" Then
                    j = j + 35
                End If
                If ListBox2.Items(i) = "Maggi(Rs.20)" Then
                    j = j + 20
                End If
                If ListBox2.Items(i) = "Sandwich(Rs.12)" Then
                    j = j + 12
                End If
                If ListBox2.Items(i) = "Chinese Puf(Rs.12)" Then
                    j = j + 12
                End If
                If ListBox2.Items(i) = "Samosa(Rs.15)" Then
                    j = j + 15
                End If
            End If
        Next i

        TextBox2.Text = j
    End Sub
End Class
-----------------------------------------output----------------------------------------------------

umesh sohaliya
codestrew

program 12: multiplication table


program to print multiplication table of given number

-----------------------------------------code---------------------------------------------------------

Imports System
Module Module1
    Sub Main()
        Dim n, i, mul As Integer
        Console.WriteLine("Enter number:-")
        n = Console.ReadLine()
        Console.WriteLine("Multiplication Table")
        For i = 1 To 10
            mul = n * i
            Console.WriteLine(n & "*" & i & "=" & mul)
        Next i
        Console.ReadKey()
    End Sub
End Module


-----------------------------------------output----------------------------------------------------


umesh sohaliya
codestrew

program 9: prime number

program to check the number is prime or not.

-----------------------------------------code---------------------------------------------------------

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, i, c As Integer
        n = TextBox1.Text
        For i = 1 To n
            If (n Mod i = 0) Then
                c = c + 1
            End If
        Next i
        If (c > 2) Then
            MsgBox("Number is not prime", , "Message")
            TextBox1.Text = ""
        Else
            MsgBox("Number is prime", , "Message")
            TextBox1.Text = ""
        End If
    End Sub
End Class

-----------------------------------------output----------------------------------------------------


umesh sohaliya
codestrew

umesh sohaliya
codestrew

program 8: find minimum & maximum value



 program to find a maximum value from five values.


-----------------------------------------code---------------------------------------------------------

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n1, n2, n3, n4, n5 As Integer
        n1 = TextBox1.Text
        n2 = TextBox2.Text
        n3 = TextBox3.Text
        n4 = TextBox4.Text
        n5 = TextBox5.Text
        If n1 > n2 And n1 > n3 And n1 > n4 And n1 > n5 Then
            TextBox7.Text = n1
        ElseIf n2 > n3 And n2 > n4 And n2 > n5 Then
            TextBox7.Text = n2
        ElseIf n3 > n4 And n3 > n5 Then
            TextBox7.Text = n3
        ElseIf n4 > n5 Then
            TextBox7.Text = n4
        Else
            TextBox7.Text = n5
        End If
        If n1 < n2 And n1 < n3 And n1 < n4 And n1 < n5 Then
            TextBox6.Text = n1
        ElseIf n2 < n3 And n2 < n4 And n2 < n5 Then
            TextBox6.Text = n2
        ElseIf n3 < n4 And n3 < n5 Then
            TextBox6.Text = n3
        ElseIf n4 < n5 Then
            TextBox6.Text = n4
        Else
            TextBox6.Text = n5
        End If
    End Sub
End Class



-----------------------------------------output----------------------------------------------------


umesh sohaliya
codestrew

program 7: prepare marksheet


program using select case marks of five subject and display the  total,percentage and class.
-----------------------------------------code---------------------------------------------------------

End ClassPublic Class Form1

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim s1, s2, s3, s4, s5 As Integer
        Dim per As Integer
        s1 = TextBox1.Text
        s2 = TextBox2.Text
        s3 = TextBox3.Text
        s4 = TextBox4.Text
        s5 = TextBox5.Text
        TextBox6.Text = s1 + s2 + s3 + s4 + s5
        TextBox7.Text = TextBox6.Text / 5
        per = TextBox7.Text
        If per >= 0 And per < 35 Then
            TextBox8.Text = "Fail"
        ElseIf per >= 35 And per < 50 Then
            TextBox8.Text = "Pass Class"
        ElseIf per >= 50 And per < 60 Then
            TextBox8.Text = "Second Class"
        ElseIf per >= 60 And per < 70 Then
            TextBox8.Text = "First Class"
        ElseIf per >= 70 And per <= 100 Then
            TextBox8.Text = "Distinction"
        End If
    End Sub
End Class

-----------------------------------------output----------------------------------------------------


umesh sohaliya
codestrew

program 6: palindrome or not.


program to check the given no. is palindrome or not.

-----------------------------------------code---------------------------------------------------------


Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, temp, a, rev As Integer
        n = TextBox1.Text
        temp = n
        While (n > 0)
            a = n Mod 10
            rev = (rev * 10) + a
            n = n / 10
        End While
        If (temp = rev) Then
            MsgBox("Number is palindrom", , "Message")
            TextBox1.Text = ""
        Else
            MsgBox("Number is not palindron", , "Message")
            TextBox1.Text = ""
        End If
    End Sub
End Class

-----------------------------------------output----------------------------------------------------

umesh sohaliya
codestrew
umesh sohaliya
codestrew

program 5: factorial.


program to print factorial number.

-----------------------------------------code---------------------------------------------------------

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim i As Integer
        Dim mul As Integer

        mul = 1
        i = TextBox1.Text
        While (i >= 1)

            mul = mul * i
            i = i - 1

        End While
        TextBox2.Text = mul
    End Sub
End Class

-----------------------------------------output----------------------------------------------------

umesh sohaliya
codestrew


program 4: year is leap or not

program to check entered year is leap or not.
-----------------------------------------code---------------------------------------------------------
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text Mod 4 = 0 Then

            MsgBox("Leap year", , "Message")
            TextBox1.Text = ""
        Else
            MsgBox("Not Leap year", , "Message")
            TextBox1.Text = ""
        End If
    End Sub
End Class


-----------------------------------------output----------------------------------------------------

umesh sohaliya
codestrew
umesh sohaliya
codestrew