Sinhgad Institute of Bussiness Administration and Computer Application Lonavala

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 66

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala

ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.1 WAP to find out Maximum among three numbers

Module Module1 Sub Main() Dim a, b, c As Integer Console.WriteLine("Enter the Values of a,b,c ") a = Console.ReadLine b = Console.ReadLine c = Console.ReadLine If a > b And a > c Then Console.WriteLine("Greater is a") ElseIf b > c Then Console.WriteLine("Greater is b") Else Console.WriteLine("Greater is c") End If Console.ReadLine() End Sub End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.2

WAP to find out grade of student depending on the score

Module Module1

Sub Main()

Dim a, b, c, avg As Integer Console.WriteLine("Enter the marks of C prog") a = Console.ReadLine Console.WriteLine("Enter the marks of SE") b = Console.ReadLine Console.WriteLine("Enter the marks of OS") c = Console.ReadLine avg = (a + b + c) / 3 Select Case avg Case Is >= 70 Console.WriteLine("Distinction") Case 60 To 69 Console.WriteLine("First class") Case 50 To 59 Console.WriteLine("Second class")

Case 40 To 49 Console.WriteLine("Third class") Case Else Console.WriteLine("fail") End Select

Console.ReadLine()

End Sub

End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.3

WAP to check entered number is even or odd

Module Module1 Sub Main() Dim num, r As Integer Console.WriteLine("Enter the number") num = Console.ReadLine If num Mod 2 = 0 Then Console.WriteLine("Entered number is Even") Else Console.WriteLine("Entered number is Odd") End If Console.ReadLine() End Sub End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


1.4 WAP to check a leap year

Class: MCA-III

Module Module1 Sub Main() Dim year As Integer Console.WriteLine("Enter year") year = Console.ReadLine

If year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0 Then Console.WriteLine("Given year is leap year....") Else Console.WriteLine("Given year is not leap year....") End If Console.ReadKey() End Sub End Module

Output: Enter year 2004 Given year is leap year

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


1.5 WAP to find out Factorial of number

Class: MCA-III

Module Module1

Sub Main()

Dim fact, num As Integer fact = 1 Console.WriteLine("Enter the value of number") num = Console.ReadLine While num > 0 fact = fact * num num = num - 1 End While

Console.WriteLine("Factorial of Number " + CStr(fact)) Console.ReadLine()

End Sub End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.6 WAP to find out the entered number is prime or not

Module Module1

Sub Main()

Dim i, p, num, c As Integer c=0 Console.WriteLine("Enter the value of number") p = Console.ReadLine For i = 1 To p If p Mod i = 0 Then c=c+1 End If Next

If c.Equals(2) Then Console.WriteLine("Number is Prime") Else Console.WriteLine("Number is not Prime") End If

Console.ReadLine() End Sub

End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


1.7

Class: MCA-III

WAP to Find out perfect number


Module Module1 Sub Main() Dim n, i, s As Integer Console.WriteLine("Enter a no:") n = Console.ReadLine() s = 0 For i = 1 To n - 1 If n Mod i = 0 Then s = s + i End If Next If (s = n) Then Console.WriteLine("perfect no") Else Console.WriteLine("not perfect no") End If Console.ReadLine()

End Module

Output Enter a number: 6 Perfect Number

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


1.8

Class: MCA-III

WAP to Find out Armstrong number

Module Module1 Sub Main() Dim no, num, remi, sum As Integer Console.WriteLine("Enter the number::") no = Console.ReadLine num = no sum = 0 Do While no > 0 remi = no Mod 10 sum = sum + (remi * remi * remi) no = no / 10 Loop If sum = num Then Console.WriteLine("No is armstrong...") Else Console.WriteLine("No is not armstrong...") End If Console.ReadKey() End Sub End Module

Output: Enter the number 153 No. is Armstrong

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.9 Write a program to print the number in reverse order Module Module1

Sub Main()

Dim num, result As Integer num = Console.ReadLine

While num > 0 result = num Mod 10 Console.Write(result) num = num / 10 End While Console.ReadLine()

End Sub

End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.10 Write a program to print the addition of digit in number

Module Module1

Sub Main()

Dim num, result, add As Integer add = 0 num = Console.ReadLine

While num > 0 result = num Mod 10 add = add + result num = num / 10 End While Console.WriteLine(add)

Console.ReadLine() End Sub

End Module

O/P :-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

1.10

Program for Exceptional Handling

Module Module1 Sub Main() Dim A, B, C As Integer A=3 B=0 Try C = A Mod B Catch Except As Exception Console.WriteLine(Except.Message()) End Try End Sub End Module

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B 1.12 WAP to Find out Max & Min numbers from Array
Module Module1

Class: MCA-III

Sub Main() Dim n(10), max, min As Integer Console.WriteLine("Enter a 10 no: in array") For i = 1 To 10 n(i) = Console.ReadLine() Next max = n(0) min = n(0) For i = 1 To 10 If max < n(i) Then max = n(i) End If Next

For i = 1 To 10 If min > n(i) Then min = n(i) End If

Next

Console.WriteLine("Max. No." & max)

Console.WriteLine("Min no" & min)

Console.ReadLine() End Sub

End Module

Output:
Enter a 10 no: in array 1 2 3 4 5 6 7 8 9 10 Max No. 10 Min No. 1

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B 2.1


Write a program to display checked hobbies .

Class: MCA-III

Design :

Code:
Dim str As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click str = "" If CheckBox1.Checked Then str = str + "," + CheckBox1.Text End If If CheckBox2.Checked Then str = str + "," + CheckBox2.Text End If If CheckBox3.Checked Then str = str + "," + CheckBox3.Text End If If CheckBox4.Checked Then str = str + "," + CheckBox4.Text End If MsgBox("your hobbies are " + str)

End Sub

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

2.2

Program . Develop a calculator application

Design:

Code:
Public Class Form1

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

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text) End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text) End Sub

Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

End Sub

Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

2.3

Write a program to design an application with checkbox 0 to 9 and after clicking on the add button display the addition. Design :

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click a=0 If CheckBox1.Checked Then a = a + CInt(CheckBox1.Text)

End If If CheckBox2.Checked Then a = a + CInt(CheckBox2.Text) End If If CheckBox3.Checked Then a = a + CInt(CheckBox3.Text) End If If CheckBox4.Checked Then a = a + CInt(CheckBox4.Text) End If If CheckBox5.Checked Then a = a + CInt(CheckBox5.Text) End If If CheckBox6.Checked Then a = a + CInt(CheckBox6.Text) End If If CheckBox7.Checked Then a = a + CInt(CheckBox7.Text) End If If CheckBox8.Checked Then a = a + CInt(CheckBox8.Text) End If If CheckBox9.Checked Then a = a + CInt(CheckBox9.Text) End If If CheckBox10.Checked Then a = a + CInt(CheckBox10.Text) End If Label3.Text = a

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


and display the result. Design:

Class: MCA-III

2.4. Write a progaem to accept two numbers from user and perform action according to the radiobuttons

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If RadioButton1.Checked Then Label3.Text = CInt(TextBox1.Text) + CInt(TextBox2.Text) End If

If RadioButton2.Checked Then Label3.Text = CInt(TextBox1.Text) - CInt(TextBox2.Text) End If End Sub

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


command buttons .

Class: MCA-III

2.5 Program . Design an application with a text box & a Combo box, & some
1. On click of Add button, add text in text box to combo. 2. On click of Delete button, the selected entry should get deleted from combo. 3. On click of any above buttons display total number of final items in list. Design:

Code:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ComboBox1.Items.Add(TextBox1.Text) TextBox1.Clear() Label2.Text = ComboBox1.Items.Count End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ComboBox1.Items.RemoveAt(ComboBox1.SelectedIndex) Label2.Text = "one items deleted" End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

2.6

Porgram Design an application with a list box having names of Operating Systems. 1. Count the number of element in listbox . 2. On click of Display button show os selected 3. On click of delete, delete the selected names. Design

Code:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

2.7. Design an application with 2 list boxes, with buttons Transfer one, all after clicking on buttons transfer either selected items or all items to 2nd list box Design:

Code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click ListBox2.Items.Add(ListBox1.SelectedItem) Label2.Text = "one End Sub item added"

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

3.8 WAP to insert, Delete a student information in student table Table name- student Database Ms-Access Design:

Code:

Imports System.Data Imports System.Data.OleDb Public Class Form1 Dim a As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click Dim s As String s = "jay" Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("insert into student values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')", conn) conn.Open() cmd.ExecuteNonQuery() Label5.Text = "Data inserted sucessfully" conn.Close() End Sub

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

Try Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("select * from student where fname='" + TextBox4.Text + "'", conn) Dim rdr As OleDbDataReader conn.Open() rdr = cmd.ExecuteReader rdr.Read() TextBox1.Text = (rdr("fname")) TextBox2.Text = (rdr("lname")) TextBox3.Text = (rdr("course")) Catch ex As Exception MsgBox(ex.Message) End Try End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("delete from student where fname='" + TextBox4.Text + "'", conn) Dim rdr As OleDbDataReader conn.Open()

rdr = cmd.ExecuteReader Label5.Text = " one record deleted sucessfully." Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala

ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

3.9 . WAP to update, modify a student information in student table Table name- student Database Ms-Access Design:

Code:

Imports System.Data Imports System.Data.OleDb Public Class Form1 Dim a As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click Dim s As String s = "jay"

Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("update student set fname='" + TextBox1.Text + "',lname='" + TextBox2.Text + "',course='" + TextBox3.Text + "')", conn) conn.Open() cmd.ExecuteNonQuery() Label5.Text = "Data updted sucessfully"

conn.Close() End Sub

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

Try Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("select * from student", conn) Dim rdr As OleDbDataReader conn.Open() rdr = cmd.ExecuteReader rdr.Read() TextBox1.Text = (rdr("fname")) TextBox2.Text = (rdr("lname")) TextBox3.Text = (rdr("course")) Catch ex As Exception MsgBox(ex.Message) End Try

End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") Dim cmd As New OleDbCommand("delete from student where fname='" + TextBox4.Text + "'", conn) Dim rdr As OleDbDataReader conn.Open() rdr = cmd.ExecuteReader Label5.Text = " one record deleted sucessfully." Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class

Output:

3.10

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

Write a program to login by username and password values if valid user then show welcome on label. Design:

Code:
Public Class Form3 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Try If TextBox1.Text = "jayant" And TextBox2.Text = "patil" Then Label4.Text = "Welcome User.." Else Label4.Text = "Invalid User.."

End If Catch ex As Exception MsgBox("Error " + ex.Message) End Try End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

3.11 Write a program to access data from database when you click on the first, next, previous, last button. Design:

Code:
Imports System.Data Imports System.Data.OleDb Public Class Form2 Inherits System.Windows.Forms.Form Dim conn As New OleDbConnection Dim adp As New OleDbDataAdapter Dim cmdbuilder As New OleDbCommandBuilder Dim ds As New DataSet Dim currow, totalrec As Integer Dim str As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click currow = 0 displaydata() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click currow = totalrec - 1

displaydata() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click If currow > 0 Then currow -= 1 End If displaydata() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If currow < totalrec - 1 Then currow += 1 End If displaydata() End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") conn.Open() str = "select * from salesman" adp = New OleDbDataAdapter(str, conn) cmdbuilder = New OleDbCommandBuilder(adp) adp.Fill(ds, "salesman") currow = 0 totalrec = ds.Tables("salesman").Rows.Count displaydata() End Sub Public Sub displaydata() TextBox1.Text = ds.Tables("salesman").Rows(currow)(0) TextBox2.Text = ds.Tables("salesman").Rows(currow)(1) TextBox3.Text = ds.Tables("salesman").Rows(currow)(2) End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

3.12 Write a program to insert values from textbox to database when you click on the insert button. Design:

Code:
Imports System.Data Imports System.Data.OleDb Public Class Form2 Dim conn As OleDbConnection Dim cmd As OleDbCommand Dim str As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Documents\new.accdb") str = "jay" Dim cmd As New OleDbCommand("INSERT INTO salesman (s_id, s_name, s_sales) VALUES ('" + TextBox1.Text + "', '" + TextBox2.Text + "', '" + TextBox3.Text + "')", conn) conn.open() cmd.ExecuteNonQuery() Label4.Text = "Data inserted sucessfully" TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() conn.Close() End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

3.13 WAP to display values from employee table in Disconnected Architecture Table name- employee Database MS-Access
Imports System.Data Imports System.Data.OleDb Public Class Form1 Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\user\Desktop\mydatabase.accdb") Dim adp As New OleDbDataAdapter("select * from Table1", cnn) Dim ds As New DataSet() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click adp.Fill(ds, "Table1") DataGridView1.DataSource = ds DataGridView1.DataMember = "Table1" End Sub End Class Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

4.1 WAP to Accept Student Rno & Name by using Write only properties and display it by

Using Readonly Properties


Public Class Class1 Dim rolno As Integer Dim name As String Public ReadOnly Property pr1() Get Return rolno End Get End Property Public ReadOnly Property pr2() As String Get Return name End Get End Property Public WriteOnly Property pr3()

Set(ByVal value) rolno = value End Set End Property Public WriteOnly Property pr4() As String Set(ByVal value As String) name = value End Set End Property End Class Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As New Class1 Dim obj1 As New Class1 obj.pr3 = TextBox1.Text obj1.pr4 = TextBox2.Text TextBox3.Text = obj.pr1 TextBox4.Text = obj1.pr2 End Sub End Class

Output:-

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

4.2 Program 18.Write a program to accept student record (roll no, name, marks) and by using find out grade of student. Design:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As New Class1 obj.setname = TextBox1.Text obj.setrollno = TextBox2.Text obj.setm1 = TextBox3.Text obj.setm2 = TextBox4.Text Label7.Text = obj.getname + " your grade is " + obj.getgrade End Sub Public Class Class1 Dim name, roll_no As String Dim grade As String Dim m1, m2 As Integer Public ReadOnly Property getname() As String Get Return name End Get End Property Public ReadOnly Property getrollno() As String Get Return roll_no End Get End Property Public ReadOnly Property getgrade() As String Get If m1 + m2 > 150 Then grade = "A" ElseIf m1 + m2 > 120 And m1 + m2 < 150 Then grade = "B" ElseIf m1 + m2 < 120 And m1 + m2 > 90 Then grade = "C" End If Return grade

End Get End Property Public WriteOnly Property setname() As String Set(ByVal value As String) name = value End Set End Property Public WriteOnly Property setrollno() As String Set(ByVal value As String) roll_no = value End Set End Property Public WriteOnly Property setm1() As Integer Set(ByVal value As Integer) m1 = value End Set End Property Public WriteOnly Property setm2() As Integer Set(ByVal value As Integer) m2 = value End Set End Property Public WriteOnly Property setgrade() As String Set(ByVal value As String) End Set End Property End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

4.3 Write a program to initialize the value of the variable by using the constructor. Design:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim no As Integer Dim obj As New Class1 TextBox2.Text = obj.Getrollno() no = CInt(TextBox1.Text) Dim obj1 As New Class1(no) TextBox3.Text = obj1.getrollno() End Sub Public Class Class1 Dim rno As Integer Sub New() rno = 100 End Sub Sub New(ByVal value As Integer) rno = value End Sub Function Getrollno() Return Rno End Function End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


4.4 Write a program for the function overloading Code:
Public Class Form1

Class: MCA-III

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As New class1() Label3.Text = obj.add(52 4) Label5.Text = add(2.9, 2.6) End Sub End Class Class class1 Overloads Function add(ByVal a As Integer, ByVal b As Integer) Return a+b End If End Function Overloads Function add(ByVal a As Double, ByVal b As Double) Return a+b End If End Function End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B

Class: MCA-III

4.5 Write a program for creation of the namespace sibaca within that add class. Code:
Namespace sibaca Class mca Dim a As String Public Property getmsg() As String Get Return a End Get Set(ByVal value As String) a = value End Set End Property End Class End Namespace Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim obj As New sibaca.mca() obj.getmsg = TextBox1.Text Label3.Text = obj.getmsg() End Sub End Class

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B Validation Control


. Design:

Class: MCA-III

5.1 : Design Web Application to accept a values from user and validate these values by using

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title>

</head> <body> <form id="form1" runat="server"> <div> </div> First Name: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage=" * Please enter your name"></asp:RequiredFieldValidator> <br /> Last Name: <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage=" * Please enter last name"></asp:RequiredFieldValidator> <br /> Email-ID:&nbsp;&nbsp;&nbsp; <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox3" ErrorMessage=" * Please enter valid email-id " ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+ ([-.]\w+)*"></asp:RegularExpressionValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" /> &nbsp;<asp:Button ID="Button2" runat="server" Text="Cancel" /> </form> </body> </html>

Output:

Sinhgad Institute Of Bussiness Administration And Computer Application Lonavala


ADT Lab

Name: Vinod Nandankar Roll No: -21 Div: B


5.2

Class: MCA-III

Design Web Application to accept a password having length greater than 7 by using Custom Validator.

Design:

Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>CustomValidator Control Sample</title> <script runat="server" language="VB"> Sub CheckUniqueUserName(s As Object, _ e As ServerValidateEventArgs) Dim username As String = e.Value.Length If (username <= "7") Then e.IsValid = False End If End Sub </script> </head> <body> <form id="Form1" runat="server"> New Password:<br /> <asp:TextBox ID="usernameTextBox" runat="server" /> <asp:CustomValidator ID="usernameUnique" runat="server" ControlToValidate="usernameTextBox" OnServerValidate="CheckUniqueUserName" ErrorMessage=" * Password should be greater than 7 char" /> <br /> <asp:Button ID="submitButton" runat="server" Text="Submit" /> </form> </body> </html>

Output:

You might also like