Thursday, 25 September 2014

VB.NET


                                                                   
Title:
       Write VB .Net  program to take three text boxes and two buttons on the form. Enter different strings in first  and second textbox. On clicking the First command button, concatenation of two strings should be displayed in third text box and on clicking second command button , reverse of string should display in third text box.         

Public Class Form1
------CODE FOR CONCATINATE STRING------

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

        TextBox3.Text = TextBox1.Text + TextBox2.Text

    End Sub

------CODE FOR REVERCE STRING------

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)    Handles Button2.Click

        TextBox3.Text = StrReverse(TextBox3.Text)

    End Sub
End Class






                                                        
Title:
    Write VB.Net program to add three text boxes at runtime. Allow user to enter values and then display Maximum and Minimum value using message box after click on command  button.   

Public Class assignment2
'----------DECLARETION OF VARIABLES OF TEXTBOX TYPE-----------
    Dim t1 As New TextBox
    Dim t2 As New TextBox
    Dim t3 As New TextBox

'---------------CODE FOR ADD THREE TEXT BOX RUN TIME VALUE-----------

    Private Sub assignment2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        t1.SetBounds(175, 80, 143, 20)
        Me.Controls.Add(t1)
        t2.SetBounds(175, 138, 145, 20)
        Me.Controls.Add(t2)
        t3.SetBounds(175, 195, 148, 20)
        Me.Controls.Add(t3)
    End Sub
'---------------CODE FOR FIND MAXIMUM AND MINIMUM VALUE-----------

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
        Dim a, b, c, min, max As Integer
        a = Val(t1.Text)
        b = Val(t2.Text)
        c = Val(t3.Text)
        If a > b And a > c Then
            max = a
        ElseIf b > a And b > c Then
            max = b
       
Else
            max = c
        End If
        If a < b And a < c Then
            min = a
        ElseIf b < a And b < c Then
            min = b
        Else
            min = c
        End If
        MsgBox("Max is=" & max & " Min is=" & min)
    End Sub
End Class

                                                         

Title:
      Write a program in VB.net to display the status of mouse using label controls program   should display current x,y positions of mouse . When user clicks left  or right
buttons label should indicate which button is pressed. Program should also indicates double click .When user clicks on close , show summery report as given below
                                                                                                                 
                                               


Public Class MouseEvents
                  ------CODE FOR CHECK MOUSE BUTTON CLICK------
    Private Sub Form1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
        Label9.ForeColor = Color.Green
        If (e.Button = Windows.Forms.MouseButtons.Right = True) Then
            TextBox1.Text = Val(TextBox1.Text) + 1
            Label9.Text = "Right click activated"
        End If
        If (e.Button = Windows.Forms.MouseButtons.Left = True) Then
            TextBox2.Text = Val(TextBox2.Text) + 1
            Label9.Text = "Left Click Activated"
        End If
    End Sub
------CODE FOR CHECK MOUSE DOUBLE CLICK------

    Private Sub Form1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDoubleClick
        TextBox3.Text = Val(TextBox3.Text) + 1
        Label9.Text = "Double Click is Activated"
    End Sub
------CODE FOR CHECK MOUSE POSITION------
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        Label8.Text = "X =" & e.X & "  Y=" & e.Y
    End Sub
------CODE FOR DISPLAY MOUSE SUMMERY------
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MsgBox("Pointer Location is=" & Label8.Text)
    End Sub
------CODE FOR DISPLAY MOUSE CLICK TIME------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("Right Click=" & Val(TextBox1.Text) & "   " & "Left Click=" & Val(TextBox2.Text) & "  " & "Double Click=" & Val(TextBox3.Text))
    End Sub
End Class

   Title:
        Write VB.Net program to design following form and Display binary , hexadecimal, and octal  number in particular text box after clicking ok Command button.

                                 

Public Class Form1
‘----------------CODE FOR FIND NUMBERS---------------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Integer
        a = Val(TextBox1.Text)
        Label5.Text = ""
        While a > 0
            Label5.Text = Label5.Text & Val(a Mod 2)
            a = a \ 2

        End While
        TextBox2.Text = StrReverse(Label5.Text)
        TextBox3.Text = Conversion.Hex(Val(TextBox1.Text))
        TextBox4.Text = Conversion.Oct(Val(TextBox1.Text))
    End Sub
------CODE FOR EXIT BUTTON------
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

End Class


                                               
Title:
        Write VB.Net program to design following form to accept date from user using  calendar control and on clicking command button display result in appropriate textbox in first textbox display date increment by 1 day and in second textbox display date decrement by 2 day by using function overloading.

                   
Public Class Form1
' ----CODE FOR DISPLAY TODAYS DATE--------

    Dim d As Date
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      
        d = MonthCalendar1.SelectionRange.Start
        Label3.Text = d
        Call showdate()
        Call showdate(d)
    End Sub

'---------CODE FOR INCREASE DATE BY 1------------

    Public Function showdate() As Date
        MonthCalendar1.SetDate(DateAdd(DateInterval.Day, 1, d))
        TextBox1.Text = MonthCalendar1.SelectionRange.Start
    End Function
    Public Function showdate(ByVal d2 As Date) As Date
'--------CODE FOR DECRISE DATE BY 2---------

        MonthCalendar1.SetDate(DateAdd(DateInterval.Day, -2, d2))
        TextBox2.Text = MonthCalendar1.SelectionRange.Start
    End Function
End Class
                                            
Title:
        Write VB.Net Program to Design following form and Display appropriate result in message box after clicking command button .                                                                          
                                               
Public Class Prime

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n, r, rev, t As Integer
        n = Val(TextBox1.Text)
        t = n
----------CODE FOR PALINDROME NUMBER---------

        If RadioButton1.Checked = True Then
            While (t > 0)
                r = t Mod 10
                rev = rev * 10 + r
                t = t / 10
            End While
            If (n <> rev) Then
                MsgBox("Number is Not Palindrome")

            Else
                MsgBox("Number is Palindrome")

            End If
        End If
----------CODE FOR PRIME NUMBER---------

        If RadioButton2.Checked = True Then
            Dim flag As Integer
            r = 2
            flag = 0
            While r < n
                If n Mod r = 0 Then
                    flag = 1
                End If
                r = r + 1
            End While
            If flag = 0 Then
                MsgBox("No is Prime")
            Else
                MsgBox("No is not Prime")
            End If

        End If
----------CODE FOR ARMSTRONG NUMBER---------

        If RadioButton3.Checked = True Then
            Dim r1 As Integer

            rev = 0

            While (n > 0)
                r1 = n Mod 10
                rev = rev + (r1 * r1 * r1)
                n = n \ 10
            End While

            If (rev <> t) Then
                MsgBox("Number Is Not Armstrong")
            Else
                MsgBox("Number Is Armstrong")
            End If
        End If
    End Sub
End Class
                                                                   
Title:
       Write VB.Net Program to Design following form to display Selected Stream &   
Computer Knowledge(Use panel) and Display following Message box. When clicked on New button  form should be reset.

                                             
Public Class Form1
‘-----CODE FOR NEW BUTTON------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        RadioButton1.Checked = False
        RadioButton2.Checked = False
        RadioButton3.Checked = False
        RadioButton4.Checked = False
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False

    End Sub
‘------CODE FOR SHOW STATUS------

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim st, ck As String
        ck = ""
        If RadioButton1.Checked = True Then
            st = "MBA"
        End If
        If RadioButton2.Checked = True Then
            st = "MCM"
        End If
        If RadioButton3.Checked = True Then
            st = "MCA"
        End If
        If RadioButton4.Checked = True Then
            st = "BCA"
        End If
        If CheckBox1.Checked = True Then
            ck = ck + "   VB.NET  "
        End If
        If CheckBox2.Checked = True Then
            ck = ck + "   C#.NET   "
        End If
        If CheckBox3.Checked = True Then
            ck = ck + "    J#.NET"
        End If
MsgBox("NAME := " & TextBox1.Text & "Stream:= " & st & " Computer Knowledge = " & ck)
    End Sub
---CODE FOR EXIT BUTTON-----
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.close()
End sub
End Class


                                                                   
Title:
         Write a program in VB.Net to do following
a)      Create a project with a single form, a command button and a common dialog control. When the command button is clicked, open the common dialog box to permit the user to change the BackColor of the form.
b)     Create a project with single form, a command button, a common dialog control and label. Use a common dialog box to permit the user to change the font size of the label.

Public Class Form1
‘------CODE FOR COLOR DIALOG-------

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)              Handles Button1.Click
        Dim obj1 As New ColorDialog
        obj1.ShowDialog()
        Me.BackColor = obj1.Color

    End Sub
‘------CODE FOR FONT DIALOG------

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim obj2 As New FontDialog
        obj2.ShowDialog()
      Label1.Font = obj2.Font

    End Sub
End Class



.                                                                        
Title:
          Write a VB.Net code for show progress bar after progress complete close a form and show MDI FORM

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
    End Sub
---------------CODE FOR SHOW PROGRESS -----------
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If ProgressBar1.Value < 100 Then
            ProgressBar1.Value = ProgressBar1.Value + 10
            Label1.Text = ProgressBar1.Value
        Else
            MDIParent1.Show()
            Timer1.Enabled = False
        End If
    End Sub
End Class
                                                                        
Title:
        Write VB .Net  program to design following form . Accept Number from user with proper validations Select   radio button ,after clicking command button display result  in textbox . If  number2 is entered as  zero and operator is division then display  error message’ Divide by Zero’ in result textbox .(use exception handling)

                     


Public Class Form1
---------CODE FOR CALCULATE BUTTON--------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b, c As Integer
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        If RadioButton1.Checked = True Then
            c = a + b
            TextBox3.Text = (“Addition is =” & c)
        End If
        If RadioButton2.Checked = True Then
            c = a – b
            TextBox3.Text = (“Subtraction is =” & c)
        End If
        If RadioButton3.Checked = True Then
            c = a * b
            TextBox3.Text = (“Multiplication is =” & c)
        End If
        Try
            If RadioButton4.Checked = True Then
                c = a / b
                TextBox3.Text = (“Divide value is =” & c)
            End If
        Catch ex As Exception
            TextBox3.Text = “Divide by Zero Error”
        End Try
 End sub
   
----------CODE FOR EXIT BUTTON----------
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click    Me.Close()    End Sub End Class
.                                                                       
Title:

Write VB.Net Program to Design following form to store numbers in single dimensional array and to find Maximum no & sum of all numbers in array.

                       
Public Class ListBox
    Dim a(5), i As Integer
----------CODE FOR DISPLAY ITEMS----------
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        For i = 0 To 4
            ListBox1.Items.Add(a(i))
        Next
    End Sub

----------CODE FOR  INPUT VALUES----------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i = 0 To 4
            a(i) = InputBox("Enter Any Value")
            If (a(i) < 0) Then
                MsgBox("Value Should be greater than Zero")
                Me.Close()
            End If
        Next
    End Sub
----------CODE FOR FIND MAXIMUM VALUE----------

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim m As Integer
        m = a(i)
        For i = 0 To 4
            If (m < a(i)) Then
                m = a(i)
            End If
        Next
        TextBox1.Text = ("Maximum Number is:=" & m)
    End Sub
----------CODE FOR ADDITION OF LIST ITEMS ELEMENT---------
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim s As Integer
        For i = 0 To 4
            s = s + a(i)
        Next
        TextBox2.Text = ("Sum of Array is:=" & s)
    End Sub
----------CODE FOR EXIT BUTTON---------

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
          Me.close()
End Sub
End Class




.                                                                       
Title:
Write a program in VB.Net to create a simple Editor. Create a button that will allow the user to access functions like File open, Save, Find.

Imports System.IO
Public Class Notepad
----------CODE FOR FILE OPEN----------
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim op As New OpenFileDialog
        Dim fo As String
        op.ShowDialog()
        fo = op.FileName
        Dim rd As StreamReader = New StreamReader(fo)
        RichTextBox1.Text = rd.ReadToEnd
        rd.Close()
    End Sub
----------CODE FOR SAVE FILE ----------

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim sd As New SaveFileDialog
        sd.ShowDialog()
        Dim sf As String
        sf = sd.FileName
        Dim sw As StreamWriter = New StreamWriter(sf)
        sw.WriteLine(RichTextBox1.Text)
        sw.Close()
    End Sub
----------CODE FOR FIND TEXT----------

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim fs, ss As String
        fs = InputBox("Enter String")
        ss = InStr(RichTextBox1.Text)
If ss Then
            RichTextBox1.Focus()
            RichTextBox1.SelectionStart = ss - 1
            RichTextBox1.SelectionLength = Len(fs)
        End If

    End Sub
End Class


                                                                                                  

No comments:

Ebook

Ebook
Ebook