vb.net
vb.net
Slip 1 Write a Vb.net program to check whether entered string is palindrome or not.
PublicClass Form1
str1 = TextBox1.Text
If str1 = StrReverse(str1) Then
MsgBox("String is palindrome")
Else
MsgBox("String is not palindrome")
EndIf
EndSub
EndClass
PublicClass Form1
EndSub
EndClass
Slip 3 Write a Vb.Net program to move the Text “NR Classes” continuously from Left to
Right.
PublicClass Form1
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.
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
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
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
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
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.
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
c = TextBox1.Text
asc1 = Asc(c)
' MsgBox(asc1)
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
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
EndSub
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
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
EndSub
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
EndSub
EndSub
EndSub
EndSub
EndSub
EndSub
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
PublicClass Form1
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
EndSub
EndSub
EndSub
EndSub
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
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
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")
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
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
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
EndSub
EndSub
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
PublicClass Form1
EndSub
EndSub
Me.CustomerTableAdapter.Fill(Me.CustDataSet.customer)
Else
MsgBox("Data not inserted")
EndIf
EndSub
EndClass
PublicClass Form1
Dim con AsNew OleDb.OleDbConnection
Dim ds AsNew DataSet
Dim da AsNew OleDb.OleDbDataAdapter
Dim cmd AsNew OleDb.OleDbCommand