NR CLASSES PUNE
BCA VB.NET SLIP SOLUTION (2015)
Slip 1 Write a Vb.net program to check whether entered string is palindrome or not.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim str1 AsString
str1 = TextBox1.Text
If str1 = StrReverse(str1) Then
MsgBox("String is palindrome")
Else
MsgBox("String is not palindrome")
EndIf
EndSub
EndClass
Slip2 Write a Vb.net program for blinking an image.
PublicClass Form1
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If PictureBox1.Visible = TrueThen
PictureBox1.Visible = False
Else
PictureBox1.Visible = True
EndIf
EndSub
EndClass
Slip 3 Write a Vb.Net program to move the Text “NR Classes” continuously from Left to
Right.
PublicClass Form1
PrivateSub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Label1.Left > 400 Then
Label1.Left = 10
EndIf
Label1.Left = Label1.Left + 15
EndSub
EndClass
Slip 4 Write a Vb.net program to accept a number from anuser through InputBox and display its
multiplication table into the ListBox.
NR Classes (8796064387 / 90) Page 1
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim no AsInteger
Dim i AsInteger
no = CInt(InputBox("Enter Number "))
For i = 1 To 10
ListBox1.Items.Add(no * i)
Next
EndSub
EndClass
Slip 5 Write a Vb.net program to accept n numbers through InputBox and count the number of
Armstrong and Perfect numbers among them and display their count by using messagebox.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim no(10) AsInteger
Dim i AsInteger
Dim num AsInteger
Dim num2 AsInteger
Dim r AsInteger
Dim armno AsInteger
Dim perfct AsInteger
Dim cntarm AsInteger
Dim cntperfct AsInteger
Dim nm AsInteger
For i = 0 To 10 - 1
no(i) = CInt(InputBox("Enter Number"))
Next
For i = 0 To 10 - 1
num = no(i)
armno = 0
perfct = 0
num2 = num
While num
r = num Mod 10
armno = armno + r * r * r
num = num \ 10
EndWhile
If armno = num2 Then
cntarm = cntarm + 1
EndIf
num = num2
nm = 1
While nm <= num2 \ 2
If num2 Mod nm = 0 Then
perfct = perfct + nm
EndIf
nm = nm + 1
EndWhile
If perfct = num Then
cntperfct = cntperfct + 1
EndIf
Next
MsgBox("Armstrong numbers "& cntarm)
NR Classes (8796064387 / 90) Page 2
MsgBox("Perfect numbers "& cntperfct)
EndSub
EndClass
Slip 6 Write a Vb.net program to add two TextBoxes, two Labels and one button at runtime.
Accept two numbers in textboxes and handle DivideByZeroException.
PublicClass Form1
Dim text1 AsNew TextBox
Dim text2 AsNew TextBox
DimWithEvents btn AsNew Button
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
'text3(i) = New TextBox
text1.Visible = True
text1.Location = New Point(20, 20)
text1.Size = New Size(150, 15)
Me.Controls.Add(text1)
text2.Visible = True
text2.Location = New Point(20, 40)
text2.Size = New Size(150, 15)
Me.Controls.Add(text2)
btn.Visible = True
btn.Location = New Point(20, 70)
btn.Size = New Size(150, 40)
btn.Text = "Click"
Me.Controls.Add(btn)
EndSub
PrivateSub btn_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btn.Click
MsgBox("Hi")
Dim a AsInteger
Try
a = CInt(text1.Text) \ CInt(text2.Text)
MsgBox("Result "& a)
Catch ex As DivideByZeroException
MsgBox(ex.Message)
EndTry
EndSub
EndClass
Slip 7 Write a Vb.net program to design following screen, accept the details from the user.
Clicking on Submit button Net Salary should be calculated and displayed into the TextBox.
Display the MessageBox informing the Name and Net Salary of employee.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
txtNetSal.Text = CInt(txtBasic.Text) + CInt(txtDA.Text) +
CInt(txtHRA.Text) + CInt(txtMA.Text) + CInt(txtPF.Text) - CInt(txtPT.Text) -
CInt(txtIT.Text)
MsgBox(txtName.Text & txtNetSal.Text)
NR Classes (8796064387 / 90) Page 3
EndSub
EndClass
Slip 8 Write a Vb.net program to accept number from user into the TextBox.Calculate the square
root of that number also convert the entered number into binary number and display result into the
Message Box
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim no AsInteger
Dim sqr AsDouble
Dim rm AsInteger
Dim str1 AsString
no = CInt(TextBox1.Text)
sqr = Math.Sqrt(no)
While no
rm = no Mod 2
str1 = str1 & rm
no = no \ 2
EndWhile
MsgBox(sqr &" and"& StrReverse(str1))
EndSub
End Class
Slip 9 Design a Vb.net form to pick a date from DateTimePicker Control and display day, month
and year in separate text boxes.
Public Class Form1
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox2.Text = Format(DateTimePicker1.Value, "dd")
TextBox3.Text = DateTimePicker1.Value.Month
TextBox4.Text = DateTimePicker1.Value.Year
EndSub
EndClass
Slip 10 Write a Vb.net program to accept a character from keyboard and check whether it is vowel
or not. Also display the case of that character.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim c AsString
Dim asc1 AsInteger
c = TextBox1.Text
asc1 = Asc(c)
' MsgBox(asc1)
NR Classes (8796064387 / 90) Page 4
If c = "a"Or c = "A"Or c = "e"Or c = "E"Or c = "i"Or c = "I"Or c = "o"Or c =
"O"Or c = "u"Or c = "U"Then
If asc1 <= 122 And asc1 >= 97 Then
MsgBox("vowel in Lowercase")
Else
MsgBox("vowel in Uppercase")
EndIf
ElseIf asc1 <= 122 And asc1 >= 97 Then
MsgBox("Not Vowel in Lowercase")
Else
MsgBox("Not Vowel in Uppercase")
EndIf
EndSub
EndClass
Slip 11 . Write a Vb.net program to accept sentences in text box and count the number of words
and display the count in message box.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sentence AsString
Dim i AsInteger
Dim wc AsInteger
sentence = TextBox1.Text
Dim arr() AsChar = sentence.ToCharArray()
For i = 0 To arr.Length - 1
If arr(i) = " "Then
wc = wc + 1
EndIf
Next
MsgBox("Total Words "& wc + 1)
EndSub
EndClass
Slip 12 Write a Vb.net program to design the following form, accept the numbers through textbox
and add them into the ListBoxe1by clicking on Add button. When user click on Prime button then all
the prime numbers from ListBox1 should get added into ListBox2.
PublicClass Form1
PrivateSub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
ListBox1.Items.Add(CInt(TextBox1.Text))
TextBox1.Text = ""
EndSub
PrivateSub btnPrime_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnPrime.Click
Dim i AsInteger
Dim cnt AsInteger
Dim num AsInteger
Dim f AsInteger
Dim j AsInteger
cnt = ListBox1.Items.Count
NR Classes (8796064387 / 90) Page 5
Try
For i = 0 To cnt - 1
num = ListBox1.Items(i)
f = 0
For j = 2 To num \ 2
If num Mod j = 0 Then
f = 1
EndIf
Next
If f = 0 Then
ListBox2.Items.Add(ListBox1.Items(i))
ListBox1.Items.RemoveAt(i)
cnt = cnt - 1
i = i - 1
EndIf
Next
Catch ex As Exception
EndTry
EndSub
EndClass
Slip 13 Write a Vb.net program to design the following form, allow the user to select radio buttons
from Gender and AgePanel. After Selection appropriate CheckBox from Right Panel should be
selected automatically. Display appropriate message into the MessageBox by clicking on Ok button.
PublicClass Form1
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If RadioButton1.Checked = TrueAnd RadioButton3.Checked = TrueOr
RadioButton2.Checked = TrueAnd RadioButton3.Checked = TrueThen
CheckBox2.Checked = True
MsgBox(TextBox1.Text &" Sorry You Dont Drive Car")
ElseIf RadioButton1.Checked = TrueAnd RadioButton4.Checked = TrueOr
RadioButton2.Checked = TrueAnd RadioButton4.Checked = TrueThen
CheckBox1.Checked = True
MsgBox(TextBox1.Text &" You can Drive Car")
Else
CheckBox3.Checked = True
MsgBox(TextBox1.Text &" It's All Right")
EndIf
EndSub
EndClass
Slip 14 Write a Vb.net program to design the following form, select the question number from
combo box that question will be displayed into textbox and the options for that question will be
displayed on four radio buttons, select option and click on submit button result should be displayed
in another textbox.
PublicClass Form1
PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "Question 1"Then
RichTextBox1.Text = "Which is capital of India?"
RadioButton1.Text = "Delhi"
RadioButton2.Text = "Mumbai"
RadioButton3.Text = "Pune"
RadioButton4.Text = "Chennai"
NR Classes (8796064387 / 90) Page 6
ElseIf ComboBox1.Text = "Question 2"Then
RichTextBox1.Text = "Which is capital of Maharashtra?"
RadioButton1.Text = "Delhi"
RadioButton2.Text = "Mumbai"
RadioButton3.Text = "Nagpur"
RadioButton4.Text = "Chennai"
EndIf
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'MsgBox(RadioButton1.Checked)
MsgBox(ComboBox1.SelectedItem)
If ComboBox1.Text = "Question 1"And RadioButton1.Checked Then
TextBox1.Text = "Answer is correct"
ElseIf ComboBox1.Text = "Question 2"And RadioButton3.Checked Then
TextBox1.Text = "Answer is correct"
Else
TextBox1.Text = "Answer is Wrong"
EndIf
EndSub
EndClass
Slip 15 Write a Vb.net program to generate Sample TreeView control shown in following form:
public class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TreeView2.Nodes.Add("Computer Science")
TreeView2.Nodes(0).Nodes.Add("BCA")
TreeView2.Nodes(0).Nodes.Add("BCS")
TreeView2.Nodes(0).Nodes.Add("MCA")
TreeView2.Nodes(0).Nodes(0).Nodes.Add("FYBCA")
TreeView2.Nodes(0).Nodes(0).Nodes.Add("SYBCA")
TreeView2.Nodes(0).Nodes(0).Nodes.Add("TYBCA")
TreeView2.Nodes(0).Nodes(1).Nodes.Add("FYBCS")
TreeView2.Nodes(0).Nodes(1).Nodes.Add("SYBCS")
TreeView2.Nodes(0).Nodes(1).Nodes.Add("TYBCS")
TreeView2.Nodes(0).Nodes(2).Nodes.Add("MCA(I)")
TreeView2.Nodes(0).Nodes(2).Nodes.Add("MCA(II)")
TreeView2.Nodes(0).Nodes(2).Nodes.Add("MCA(III)")
'TreeView2.Nodes.Add("2Main Menu")
'TreeView2.Nodes(1).Nodes.Add("Submenu")
End Sub
End Class
Slip 16 Write a Vb.net program to design the following form, it contains the three menus Color
(Red,Blue,Green) ,Window(Maximize, Minimize, Restore) and Exit. On Selection of any menu or
submenu result should affect the form control( for example if user selected Red color from Color
menu back color of form should get changed to Red and if user selected Maximize from Window
Menu then form should get maximized).
PublicClass Form1
NR Classes (8796064387 / 90) Page 7
PrivateSub RedToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles RedToolStripMenuItem.Click
Me.BackColor = Color.Red
EndSub
PrivateSub GreenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles GreenToolStripMenuItem.Click
Me.BackColor = Color.Green
EndSub
PrivateSub BlueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BlueToolStripMenuItem.Click
Me.BackColor = Color.Blue
EndSub
PrivateSub MaximizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MaximizeToolStripMenuItem.Click
Me.WindowState = FormWindowState.Maximized
EndSub
PrivateSub MinimizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MinimizeToolStripMenuItem.Click
Me.WindowState = FormWindowState.Minimized
EndSub
PrivateSub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CloseToolStripMenuItem.Click
Me.WindowState = FormWindowState.Normal
EndSub
PrivateSub ExToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ExToolStripMenuItem.Click
End
EndSub
EndClass
Slip 17 Write a Vb.net program to design the following form, this program shows the details of
students in the form of form (use split container or Groupbox control to separate the input and output
session).
PublicClass Form1
PrivateSub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Label1.Text = txtName.Text
Label2.Text = txtFathersName.Text
Label3.Text = txtMothersName.Text
Label4.Text = cmbCourse.Text
If optMale.Checked = TrueThen
Label5.Text = "Male"
Else
Label5.Text = "Female"
EndIf
Label6.Text = DateTimePicker1.Value
Label7.Text = txtHobbies.Text
Label8.Text = txtContact.Text
NR Classes (8796064387 / 90) Page 8
EndSub
EndClass
Slip 18 Write a Vb.net program to design the following form, accept all details from user and
display the details through message box.
PublicClass Form1
PrivateSub btnOk_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOk.Click
Dim nm AsString
Dim post AsString
Dim qual AsString = ""
nm = TextBox1.Text
If opManager.Checked = TrueThen
post = "Manager"
ElseIf opEng.Checked = TrueThen
post = "Engineer"
ElseIf opAcc.Checked = TrueThen
post = "Accountant"
Else
post = "Clerk"
EndIf
If chkBE.Checked Then
qual = qual &"BE, "
EndIf
If chkMBA.Checked Then
qual = qual &"MBA, "
EndIf
If chkCA.Checked Then
qual = qual &"CA, "
EndIf
If chkGraduate.Checked Then
qual = qual &"Graduate"
EndIf
MessageBox.Show("Name: "& nm &" Post: "& post &" Qualification: "& qual,
"Details", MessageBoxButtons.OK, MessageBoxIcon.Information)
EndSub
EndClass
Slip 19 Develop the menu based Vb.net application to implement a text editor with cut, copy,
paste, save, close operations.
Imports System.IO
PublicClass Form1
Dim s AsNew SaveFileDialog
Dim sw As StreamWriter
Dim filename AsString
PrivateSub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CloseToolStripMenuItem.Click
End
EndSub
PrivateSub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
EndSub
NR Classes (8796064387 / 90) Page 9
PrivateSub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox2.Paste()
EndSub
PrivateSub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
EndSub
PrivateSub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveToolStripMenuItem.Click
If s.ShowDialog = Windows.Forms.DialogResult.OK Then
filename = s.FileName
sw = New StreamWriter(filename)
sw.Write(RichTextBox1.Text)
sw.Close()
EndIf
EndSub
EndClass
Slip 20 Write a VB.NET program to do the following operations on RichTextBox values
i) Font Style ii) Font Color iii) Save iv) Open
Imports System.IO
PublicClass Form1
Dim f AsNew FontDialog
Dim c AsNew ColorDialog
Dim s AsNew SaveFileDialog
Dim op AsNew OpenFileDialog
Dim filename AsString
Dim searh AsString
Dim sw As StreamWriter
Dim sr As StreamReader
PrivateSub Form1_Resize(ByVal sender AsObject, ByVal e As System.EventArgs)
HandlesMe.Resize
RichTextBox1.Size = Me.Size
EndSub
PrivateSub FontStyleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles FontStyleToolStripMenuItem.Click
If f.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.Font = f.Font
EndIf
EndSub
PrivateSub FontColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles FontColorToolStripMenuItem.Click
If c.ShowDialog() = Windows.Forms.DialogResult.OK Then
RichTextBox1.ForeColor = c.Color
EndIf
EndSub
PrivateSub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveToolStripMenuItem.Click
If s.ShowDialog = Windows.Forms.DialogResult.OK Then
NR Classes (8796064387 / 90) Page 10
filename = s.FileName
sw = New StreamWriter(filename)
sw.Write(RichTextBox1.Text)
sw.Close()
EndIf
EndSub
PrivateSub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
If op.ShowDialog = Windows.Forms.DialogResult.OK Then
'Process.Start(op.FileName)
sr = New StreamReader(op.OpenFile)
RichTextBox1.Text = sr.ReadToEnd()
sr.Close()
EndIf
EndSub
EndClass
Slip 21 Write a VB.NET program to create a table Patient (Pid,PName,Contact_No, Disease). Insert
records into table and display appropriate message in message box. (Use MS Access to create db)
PublicClass Form1
Dim con AsNew OleDb.OleDbConnection
Dim da AsNew OleDb.OleDbDataAdapter
Dim ds AsNew DataSet
Dim DbProvider AsString
Dim DbSource AsString
Dim query AsString
Dim cmd AsNew OleDb.OleDbCommand
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
DbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
DbSource = "Data Source = D:\Documents_backup\patient.mdb"
con.ConnectionString = DbProvider & DbSource
con.Open()
query = "Select * from pat"
da = New OleDb.OleDbDataAdapter(query, con)
da.Fill(ds, "pat")
DataGridView1.DataSource = ds.Tables("pat")
EndSub
PrivateSub btnInsert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnInsert.Click
Dim x AsInteger
Try
query = "insert into pat values("&CInt(TextBox4.Text) &",'"&
TextBox1.Text &" ',' "& TextBox2.Text &" ', ' "& TextBox3.Text &" ')"
cmd = New OleDb.OleDbCommand(query, con)
x = cmd.ExecuteNonQuery()
If (x) Then
MsgBox("Data Inserted")
Else
MsgBox("data Not inserted")
EndIf
Catch ex As Exception
MsgBox(ex)
EndTry
ds.Tables.Clear()
query = "Select * from pat"
da = New OleDb.OleDbDataAdapter(query, con)
da.Fill(ds, "pat")
NR Classes (8796064387 / 90) Page 11
DataGridView1.DataSource = ds.Tables("pat")
EndSub
EndClass
Slip 23 Write a VB.NET program to create a table student (RollNo,SName, Class). Insert the records
(Max: 5). Update class of students to „TYBCA‟ whose class is „SYBCA‟ and display updated
records in GridView. (Use MS Access to create db)
PublicClass Form1
Dim con AsNew OleDb.OleDbConnection
Dim da AsNew OleDb.OleDbDataAdapter
Dim ds AsNew DataSet
Dim cmd AsNew OleDb.OleDbCommand
Dim query AsString
Dim dbProvider AsString
Dim dbSource AsString
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source=C:\Users\Ramdas\Documents\studentmdb.mdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
da = New OleDb.OleDbDataAdapter("select * from std", con)
da.Fill(ds, "st")
DataGridView1.DataSource = ds.Tables("st")
EndSub
PrivateSub btnUpdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
Dim x AsInteger
query = "update std set sclass='tybca' where sclass='sybca'"
cmd = New OleDb.OleDbCommand(query, con)
Try
x = cmd.ExecuteNonQuery()
If (x) Then
MsgBox("Data Updated")
Else
MsgBox("No data to update")
EndIf
ds.Tables.Clear()
da = New OleDb.OleDbDataAdapter("select * from std", con)
da.Fill(ds, "st")
DataGridView1.DataSource = ds.Tables("st")
Catch ex As Exception
MsgBox("Exception Occured")
EndTry
EndSub
EndClass
Slip 25 Write a VB.NET program to create movie table (Mv_Name,Release_year, Director). Insert
therecords(Max: 5). Delete the records of movies whose release year is 2015 and display appropriate
message in messagebox.(Use MS Access to create db)
PublicClass Form1
PrivateSub MovBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MovBindingNavigatorSaveItem.Click
Me.Validate()
Me.MovBindingSource.EndEdit()
NR Classes (8796064387 / 90) Page 12
Me.TableAdapterManager.UpdateAll(Me.MovDataSet)
EndSub
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
'TODO: This line of code loads data into the 'MovDataSet.mov' table. You can
move, or remove it, as needed.
Me.MovTableAdapter.Fill(Me.MovDataSet.mov)
EndSub
PrivateSub bttn_del_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bttn_del.Click
IfMe.MovTableAdapter.DeleteQuery() Then
MsgBox("Deleted")
Me.MovTableAdapter.Fill(Me.MovDataSet.mov)
Else
MsgBox("No record to be deleted")
EndIf
EndSub
EndClass
NOTE : We have use the wizard connectivity in this program so less code required to write
Slip 26 Write a VB.NET program to accept the details of customer (CName,Contact_No,Email_id).
Store it into the database with proper validation and display appropriate message by using
Messagebox.(Use MS Access )
PublicClass Form1
PrivateSub CustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CustomerBindingNavigatorSaveItem.Click
Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.CustDataSet)
EndSub
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
'TODO: This line of code loads data into the 'CustDataSet.customer' table. You
can move, or remove it, as needed.
Me.CustomerTableAdapter.Fill(Me.CustDataSet.customer)
EndSub
PrivateSub btninsert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btninsert.Click
IfMe.CustomerTableAdapter.InsertQuery(txtname.Text, txtcontact.Text,
txtemail.Text) Then
MsgBox("Data inserted")
Me.CustomerTableAdapter.Fill(Me.CustDataSet.customer)
Else
MsgBox("Data not inserted")
EndIf
EndSub
EndClass
NR Classes (8796064387 / 90) Page 13
Slip 29 Write a VB.NET program to create Author table (aid,aname,book_name). Insert the records
(Max 5). Delete a record of author who has written “VB.NET book” and display remaining records
onthe Crystal Report.(Use MS Access to create db)
PublicClass Form1
Dim con AsNew OleDb.OleDbConnection
Dim ds AsNew DataSet
Dim da AsNew OleDb.OleDbDataAdapter
Dim cmd AsNew OleDb.OleDbCommand
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Users\Ramdas\Documents\auth.mdb"
con.Open()
da = New OleDb.OleDbDataAdapter("select * from auther", con)
da.Fill(ds, "ath")
DataGridView1.DataSource = ds.Tables("ath")
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim q AsString
Dim x AsInteger
q = "delete from auther where bname='VB.NET'"
cmd = New OleDb.OleDbCommand(q, con)
Try
x = cmd.ExecuteNonQuery()
If (x) Then
MsgBox("Data Deleted")
Else
MsgBox("Data not deleted")
EndIf
ds.Tables.Clear()
da = New OleDb.OleDbDataAdapter("select * from auther", con)
da.Fill(ds, "ath")
DataGridView1.DataSource = ds.Tables("ath")
Catch ex As Exception
MsgBox("Exception Occured")
EndTry
EndSub
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Form2.Show()
EndSub
EndClass
For More Queries: HTTP://RAMDASBIRADAR.BLOGSPOT.IN
NR Classes (8796064387 / 90) Page 14