VB .NET

VB .NET

Slip12

Q.1) Write a Vb.net program to design the following form, accept the numbers through textbox and add them into the ListBoxe1 by clicking on Add button. When user click on Prime button then all the  prime numbers from ListBox1 should get added into ListBox2.    [Marks 20] 

Solution

Public Class Slip12

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

        Dim n As Integer

        n = TextBox1.Text

        ListBox1.Items.Add(n)

    End Sub


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

        Dim flag, i, j, cnt, n As Integer

        cnt = ListBox1.Items.Count

        For i = 0 To cnt - 1

            n = ListBox1.Items(i)

            flag = 0

            For j = 2 To n / 2

                If n Mod j = 0 Then

                    flag = 1

                End If

            Next

            If flag = 0 Then

                ListBox2.Items.Add(ListBox1.Items(i))

            End If

        Next

    End Sub

End Class

BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post