Ehelp.yolasite.com



EX.NO: 1 *********************************************************************** Write a program to find the Sum of digit and check palindrome or not and display the results in text box and label.*********************************************************************** Public Class Form1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click Me.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngenerate.Click Dim n, r, rev, n1, sum As Integer n = txtno.Text rev = 0 sum = 0 n1 = n If (txtno.Text = "") Then MsgBox("enter the no") Else While (n > 0) r = n Mod 10 rev = rev * 10 + r sum = sum + r n = n / 10 End While If (rev = n1) Then lblresult.Text = Str(n1) + "is palindrome" Else lblresult.Text = Str(n1) + "is not palindrome" End If End If txtsum.Text = sum End Sub Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click txtno.Text = "" txtsum.Text = "" End SubEnd ClassOUTPUT:EX.NO: 2 *********************************************************************** Write a program to count the number of vowels, words, digits, special characters in an inputted screen and display***********************************************************************Public Class Form1 Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click Me.Close() End Sub Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click TxtA.Text = "" txtE.Text = "" txtI.Text = "" TxtO.Text = "" TxtU.Text = "" TxtVowels.Text = "" TxtDigits.Text = "" TxtSplChar.Text = "" TxtWords.Text = "" TxtStrings.Text = "" Txtinput.Text = "" End Sub Private Sub Txtinput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txtinput.TextChanged If Txtinput.Text = "" Then MsgBox("enter string ", MsgBoxStyle.Exclamation, "Vowels") End If End Sub Private Sub BtnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFind.Click Dim st, st1 As String Dim L, i As Integer Dim acount, icount, ocount, ucount, ecount, vcount, scount, wcount, ncount, sccount As Integer st = Trim(Txtinput.Text) st = LCase(st) l = Len(st) For i = Len(st) To 1 Step -1 st1 = Mid(st, i, 1) If st1 = "a" Then acount = acount + 1 vcount = vcount + 1 ElseIf st1 = "e" Then ecount = ecount + 1 vcount = vcount + 1 ElseIf st1 = "i" Then icount = icount + 1 vcount = vcount + 1 ElseIf st1 = "o" Then ocount = ocount + 1 vcount = vcount + 1 ElseIf st1 = "u" Then ucount = ucount + 1 vcount = vcount + 1 End If If (Asc(st1) >= 65 And Asc(st1) <= 90 Or Asc(st1) >= 97 And Asc(st1) <= 122) Then scount = scount + 1 ElseIf (Asc(st1) >= 48 And Asc(st1) <= 57) Then ncount = ncount + 1 ElseIf (st1 = " " Or st1 = "\t" Or st1 = "\n") Then wcount = wcount + 1 Else sccount = sccount + 1 End If Next i TxtA.Text = CStr(acount) txtE.Text = CStr(ecount) txtI.Text = CStr(icount) TxtO.Text = CStr(ocount) TxtU.Text = CStr(ucount) TxtVowels.Text = CStr(vcount) TxtDigits.Text = CStr(ncount) TxtSplChar.Text = CStr(sccount) TxtWords.Text = CStr(wcount + 1) TxtStrings.Text = CStr(scount) End Sub End ClassOUTPUT:EX.NO: 3 **********************************************************************Write a program to select a course from a list box and display the fees and regulation using the text boxes and labels (Fees maintained in an array in the program) *********************************************************************Public Class Form1 Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click Me.Close() End Sub Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click Txt1Year.Text = "" Txt2Year.Text = "" Txt3Year.Text = "" Label5.Text = "" End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lstcourse.Items.Add("BCA") lstcourse.Items.Add("BBM") lstcourse.Items.Add("BCOM") lstcourse.Items.Add("BA") End Sub Private Sub lstcourse_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstcourse.SelectedIndexChanged Dim BCA As Integer() BCA = New Integer() {25000, 23000, 20000} Dim BBM As Integer() = New Integer() _ {10000, 9700, 8000} Dim BCOM As Integer() = New Integer() _ {12000, 13000, 10900} Dim BA As Integer() = New Integer() _ {12000, 7000, 8500} If lstcourse.SelectedItem = "BCA" Then Txt1Year.Text = BCA(0) Txt2Year.Text = BCA(1) Txt3Year.Text = BCA(2) Label5.Text = "student from commerce & scince background with passing parcentage of 50%" ElseIf lstcourse.SelectedItem = "BBM" Then Txt1Year.Text = BBM(0) Txt2Year.Text = BBM(1) Txt3Year.Text = BBM(2) Label5.Text = "student from commerce & scince background with passing parcentage of 40%" ElseIf lstcourse.SelectedItem = "BCOM" Then Txt1Year.Text = BCOM(0) Txt2Year.Text = BCOM(1) Txt3Year.Text = BCOM(2) Label5.Text = "student from commerce & scince background with passing parcentage of 45%" ElseIf lstcourse.SelectedItem = "BA" Then Txt1Year.Text = BA(0) Txt2Year.Text = BA(1) Txt3Year.Text = BA(2) Label5.Text = "student from commerce & Arts background with passing parcentage of 50%" End If End SubEnd ClassOUTPUT:EX.NO: 4 ***********************************************************************Create an MDI form with several child forms. (At least 3 with proper information) Use menu options to open all child for/ms together, closing them and rearrange the child forms.Child FormsWindowOpenCascadeCloseTile Horizontal Tile vertical Arrange icons.**********************************************************************Public Class Form1 Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click Dim fm2 As New form2 Dim fm3 As New form3 Dim fm4 As New form4 fm2.show() fm3.show() fm4.show() fm2.mdiparent = Me fm3.mdiparent = Me fm4.mdiparent = Me ToolStripStatusLabel1.Text = "Child forms" Me.LayoutMdi(MdiLayout.Cascade) End Sub Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click 'Close all Child forms of Parent. For Each Childform As Form In Me.MdiChildren Childform.Close() Next End Sub Private Sub CascadeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CascadeToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.Cascade) End SubPrivate Sub TilehorizontalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TilehorizontalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileHorizontal) End Sub Private Sub TileverticalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TileverticalToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.TileVertical) End Sub Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ArrangeIconsToolStripMenuItem.Click Me.LayoutMdi(MdiLayout.ArrangeIcons) End SubEnd ClassPublic Class Form2 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With Label1 .Height = 1000 .Width = 4000 .Text = "Carmel college modankap" .ForeColor = Color.Blue .BackColor = Color.Aqua End With With RichTextBox1 .Height = 1000 .Width = 4000 RichTextBox1.Text = "Carmel college modankap,is a new venue..." .ForeColor = Color.Brown .BackColor = Color.Aqua End With End SubEnd ClassPublic Class Form3 Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With Label1 .Height = 1000 .Width = 4000 .Text = "College Crest and Motto" .ForeColor = Color.Blue .BackColor = Color.Aqua End With With RichTextBox1 .Height = 1000 .Width = 4000 RichTextBox1.Text = "Thy Light Our Guide" .ForeColor = Color.Brown .BackColor = Color.Aqua End With End SubEnd ClassPublic Class Form4 Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load With Label1 .Height = 1000 .Width = 4000 .Text = "Carmel college Vision" .ForeColor = Color.Blue .BackColor = Color.Aqua End With With RichTextBox1 RichTextBox1.Text = "The Gradute Students of Carmel College shall imbibe the values and become persons for others,at the same time they will be knoweledgeable,confident abd principle-centred humane persons." .ForeColor = Color.Brown .BackColor = Color.Aqua End With End SubEnd ClassOUTPUT: EX.NO: 5 **********************************************************************Design a VB interface containingA picture box whose picture should be changed every 5 second (use 5 pictures) .Textboxes to display date & time and day greeting based on time.Use scrollbars to control font size and background color (RGB) of the textbox that shows greeting.**********************************************************************Public Class Form1 Dim s As Integer = 0 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Static s As Integer Select Case (s) Case 1 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg") Case 2 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg") Case 3 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg") Case 4 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\avi.jpg") Case 5 PictureBox1.Image = Image.FromFile("C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\b.jpg") s = 0 End Select s = s + 1 End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Txtdate.Text = Format(Now, "dddd,mmmm d,yyy") & " " & Format(Now, "hh:mm:ss") If (TimeString >= "00:00:01" And TimeString <= "11:59:59") Then Txtgreet.Text = "Good Morning" ElseIf (TimeString >= "12:00:01" And TimeString <= "15:59:59") Then Txtgreet.Text = "Good Afternoon" ElseIf (TimeString >= "16:00:00" And TimeString <= "17:59:59") Then Txtgreet.Text = "Good Evening" Else Txtgreet.Text = "Good Night" End If HScrollBar4.Maximum = 60 HScrollBar4.Minimum = 10 HScrollBar4.SmallChange = 2 HScrollBar4.LargeChange = 5 End SubPrivate Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll 'Call docolor() HScrollBar1_change() End Sub Private Sub HScrollBar1_change() Call docolor() End Sub Private Sub HScrollBar2_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar2.Scroll 'Call docolor() HScrollBar2_change() End Sub Private Sub HScrollBar2_change() Call docolor() End Sub Private Sub HScrollBar3_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar3.Scroll 'Call docolor() HScrollBar3_change() End Sub Private Sub HScrollBar3_change() Call docolor() End Sub Private Sub docolor() Dim clr As Color clr = Color.FromArgb(HScrollBar1.Value, HScrollBar2.Value, HScrollBar3.Value) txtgreet.BackColor = clrEnd Sub Private Sub HScrollBar4_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar4.Scroll txtgreet.Font = New System.Drawing.Font("Times new roman", HScrollBar4.Value) End SubOUTPUT:EX.NO: 6 ***********************************************************************Create a file browser (similar to Windows Explorer). The file browser should have a Tree View, which allows the user to browse directories and double-clicking a directory in the Tree View should browse it. Create Tree Views in Code.(3 child directories)***********************************************************************Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TreeView1.Nodes.Clear() Dim root = New TreeNode("D:") TreeView1.Nodes.Add(root) TreeView1.Nodes(0).Nodes.Add(New TreeNode("avin")) TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("images")) TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("my documents")) TreeView1.Nodes(0).Nodes(0).Nodes(1).Nodes.Add(New TreeNode("My Music")) TreeView1.Nodes(0).Nodes(0).Nodes(1).Nodes.Add(New TreeNode("My Pictures")) TreeView1.Nodes(0).Nodes(0).Nodes.Add(New TreeNode("ankush")) Me.Text = "MY COMPUTER" End Sub Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Label1.Text = e.Node.FullPath Label2.Text = e.Node.Text End Sub Private Sub TreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick System.Diagnostics.Process.Start(e.Node.FullPath) End SubEnd ClassOUTPUT:EX.NO: 1 **********************************************************************Create a VB interface with menu options STRING and NUMBER. Under String use option TOGGLE CASE (convert lower to uppercase and upper to lowercase letters) and NUMBER use option FACTORIAL. Use user defined functions to find FACTORIAL and TOGGLE CASE. If the option selected is NUMBER, apply the validation for entering only the +ve number. Accept the necessary inputs through input box.**********************************************************************Public Class toggleform Private Sub toggleform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TextBox1.Text = InputBox("enter string", "string") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click toggle() End Sub Function toggle() As String Dim str As String Dim i As Integer Dim res As String Dim txt As String txt = TextBox1.Text For i = 0 To txt.Length - 1 str = txt.Chars(i) If System.Char.IsLower(str) Then res = str.ToUpper Else res = str.ToLower End If TextBox2.Text = TextBox2.Text & res Next Return (TextBox2.Text) End FunctionEnd ClassPublic Class Factform Private Sub Factform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a As Integer a = CInt(InputBox("enter number", "number")) TextBox2.Text = factorial(a) End Sub Function factorial(ByVal number) As Long If number <= 1 Then Return (1) Else Return number * factorial(number - 1) End If End FunctionEnd ClassOUTPUT: EX.NO: 2 **********************************************************************Design a VB interface to add, remove, search and clear the items in a combo box. The item name to be added, removed or searched can be accepted through input box. Use a general procedure to find the existence of item before deleting or while searching.**********************************************************************Public Class Form1 Dim item As String Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click item = InputBox("enter string", "string") ComboBox1.Items.Add(item) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click item = InputBox("remove string", "string") If ComboBox1.Items.Contains(item) Then ComboBox1.Items.Remove(item) MsgBox(item & " " & "removed", ) Else MsgBox("No item found",MsgBoxStyle.Exclamation) End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click item = InputBox("search string", "string") If ComboBox1.Items.Contains(item) Then MsgBox(item & " " & "search") Else MsgBox("No item found", MsgBoxStyle.Critical) End If End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click item = InputBox("clear string", "string") If ComboBox1.Items.Contains(item) Then MsgBox(item & " " & "clear") Else MsgBox("No item found") End If End SubEnd ClassOUTPUT:EX.NO: 3 **********************************************************************Write a program to invoke a default color dialog box, default font dialog box by instantiating the color dialog class and font dialog class respectively.********************************************************************** Public Class Form1 Private Sub BtnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnColor.Click colordialog1.color = Me.BackColor ColorDialog1.AllowFullOpen = True If ColorDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then RichTextBox1.ForeColor = ColorDialog1.Color End If End Sub Private Sub BtnFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFont.Click FontDialog1.Font = RichTextBox1.Font If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then RichTextBox1.Font = FontDialog1.Font() End If End SubEnd ClassOUTPUT:EX.NO: 4 **********************************************************************Write a program that allows the user to enter Strings in a Textbox. Each String input is added to a List Box. As each String is added to the List Box, ensure that the Strings are in sorted order. Any sorting method may be used. [Note: Do not use property Sort]**********************************************************************Public Class Form1 Dim i, n, j As Integer Dim words(10), temp As String Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnexit.Click Me.Close() End Sub Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnclear.Click TextBox1.Text = "" ListBox1.Items.Clear() End Sub Private Sub Btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnadd.Click n = ListBox1.Items.Count If n <= 0 Then ListBox1.Items.Add(TextBox1.Text) Else ListBox1.Items.Add(TextBox1.Text) End If sort() ListBox1.Items.Clear() For i = 0 To n - 1 ListBox1.Items.Add(words(i)) Next TextBox1.Clear() TextBox1.Focus() End Sub Function sort() n = ListBox1.Items.Count For i = 0 To n - 1 words(i) = CStr(ListBox1.Items(i)) Next For i = 0 To n - 1 For j = 0 To i If StrComp(words(i), words(j)) < 0 Then temp = words(i) words(i) = words(j) words(j) = temp End If Next Next Return words End FunctionEnd ClassOUTPUT:EX.NO: 5 **********************************************************************Design a simple calculator to perform addition, multiplication, subtraction and division. It should contain digits 0-9, clear , dot , = ,+, -,*, /Apply the validation rules to avoid entering dot more than once in a number. – Symbol can be used as operator as well as for negative numbers. Any operand can be negative. (Use control arrays)**********************************************************************Public Class Form1 Dim cleardisplay As Boolean Dim operand1 As Double Dim operand2 As Double Dim operator1 As String Private Sub digit_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn0.Click, Btn1.Click, Btn2.Click, Btn3.Click, Btn4.Click, Btn5.Click, Btn6.Click, Btn7.Click, Btn8.Click, Btn9.Click If cleardisplay Then Label1.Text = " " cleardisplay = False End If Label1.Text = Label1.Text & sender.text End Sub Private Sub BtnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClear.Click Label1.Text = " " End Sub Private Sub Btnplus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnplus.Click operand1 = Val(Label1.Text) operator1 = "+" cleardisplay = True End Sub Private Sub Btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnminus.Click operand1 = Val(Label1.Text) operator1 = "-" cleardisplay = True End Sub Private Sub Btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndiv.Click operand1 = Val(Label1.Text) operator1 = "/" cleardisplay = True End Sub Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click operand1 = Val(Label1.Text) operator1 = "*" cleardisplay = True End Sub Private Sub Btndot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndot.Click If Label1.Text.IndexOf(".") > 0 Then Exit Sub Else Label1.Text = Label1.Text & "." End If End Sub Private Sub Btnequal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnequal.Click Dim res As Double operand2 = Val(Label1.Text) Select Case operator1 Case "+" res = operand1 + operand2 Case "-" res = operand1 - operand2 Case "*" res = operand1 * operand2 Case "/" res = operand1 / operand2 End Select Label1.Text = res cleardisplay = True End SubEnd ClassOUTPUT:EX.NO: 6 **********************************************************************Design VB interface to conduct simple multiple choice Quiz with at least 5 questions. Use radio button for selecting the answers. One question can be answered only once. Show the total score through the message box when the user wishes.**********************************************************************Public Class Form1 Dim score As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "WHICH IS THE NATIONAL ANIMAL OF INDIA" RadioButton1.Text = "Lion" RadioButton2.Text = "Tiger" RadioButton3.Text = "Elephant" RadioButton4.Text = "Dog" Label2.Text = "WHICH IS THE NATIONAL BIRD OF INDIA" RadioButton5.Text = "Peacock" RadioButton6.Text = "Parrot" RadioButton7.Text = "Robin" RadioButton8.Text = "Crow” Label3.Text = "WHO IS OUR FATHER OF THE NATION" RadioButton9.Text = "Abdul Kalam" RadioButton10.Text = "Bose" RadioButton11.Text = "Mahatma Gandhiji" RadioButton12.Text = "Anna Hazare" Label4.Text = "WHO IS THE GOD FATHER OF CRICKET" RadioButton13.Text = "Dhoni" RadioButton14.Text = "Dravid" RadioButton15.Text = "sachin" RadioButton16.Text = "Kapil Dev" Label5.Text = "WHICH IS THE NATIONAL FLOWER OF INDIA" RadioButton17.Text = "Lotus" RadioButton18.Text = "Rose" RadioButton19.Text = "lilli" RadioButton20.Text = "Jasmine" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click if RadioButton2.Checked = True score = score + 10 End If If RadioButton5.Checked = True Then score = score + 10 End If If RadioButton11.Checked = True Then score = score + 10 End If If RadioButton15.Checked = True Then score = score + 10 End If If RadioButton17.Checked = True Then score = score + 10 End If MsgBox("score" & score) End Sub Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged RadioButton1.Enabled = False RadioButton2.Enabled = False RadioButton3.Enabled = False RadioButton4.Enabled = False End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged RadioButton1.Enabled = False RadioButton2.Enabled = False RadioButton3.Enabled = False RadioButton4.Enabled = False End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged RadioButton1.Enabled = False RadioButton2.Enabled = False RadioButton3.Enabled = False RadioButton4.Enabled = False End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged RadioButton1.Enabled = False RadioButton2.Enabled = False RadioButton3.Enabled = False RadioButton4.Enabled = False End Sub Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged RadioButton5.Enabled = False RadioButton6.Enabled = False RadioButton7.Enabled = False RadioButton8.Enabled = False End Sub Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged RadioButton5.Enabled = False RadioButton6.Enabled = False RadioButton7.Enabled = False RadioButton8.Enabled = False End Sub Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged RadioButton5.Enabled = False RadioButton6.Enabled = False RadioButton7.Enabled = False RadioButton8.Enabled = False End Sub Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged RadioButton5.Enabled = False RadioButton6.Enabled = False RadioButton7.Enabled = False RadioButton8.Enabled = False End Sub Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged RadioButton9.Enabled = False RadioButton10.Enabled = False RadioButton11.Enabled = False RadioButton12.Enabled = False End Sub Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton10.CheckedChanged RadioButton9.Enabled = False RadioButton10.Enabled = False RadioButton11.Enabled = False RadioButton12.Enabled = False End Sub Private Sub RadioButton11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton11.CheckedChanged RadioButton9.Enabled = False RadioButton10.Enabled = False RadioButton11.Enabled = False RadioButton12.Enabled = False End Sub Private Sub RadioButton12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton12.CheckedChanged RadioButton9.Enabled = False RadioButton10.Enabled = False RadioButton11.Enabled = False RadioButton12.Enabled = False End Sub Private Sub RadioButton13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton13.CheckedChanged RadioButton13.Enabled = False RadioButton14.Enabled = False RadioButton15.Enabled = False RadioButton16.Enabled = False End Sub Private Sub RadioButton14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton14.CheckedChanged RadioButton13.Enabled = False RadioButton14.Enabled = False RadioButton15.Enabled = False RadioButton16.Enabled = False End Sub Private Sub RadioButton15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton15.CheckedChanged RadioButton13.Enabled = False RadioButton14.Enabled = False RadioButton15.Enabled = False RadioButton16.Enabled = False End Sub Private Sub RadioButton16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton16.CheckedChanged RadioButton13.Enabled = False RadioButton14.Enabled = False RadioButton15.Enabled = False RadioButton16.Enabled = False End Sub Private Sub RadioButton17_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton17.CheckedChanged RadioButton17.Enabled = False RadioButton18.Enabled = False RadioButton19.Enabled = False RadioButton20.Enabled = False End Sub Private Sub RadioButton18_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton18.CheckedChanged RadioButton17.Enabled = False RadioButton18.Enabled = False RadioButton19.Enabled = False RadioButton20.Enabled = False End Sub Private Sub RadioButton19_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton19.CheckedChanged RadioButton17.Enabled = False RadioButton18.Enabled = False RadioButton19.Enabled = False RadioButton20.Enabled = False End Sub Private Sub RadioButton20_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton20.CheckedChanged RadioButton17.Enabled = False RadioButton18.Enabled = False RadioButton19.Enabled = False RadioButton20.Enabled = False End SubEnd ClassOUTPUT: EX.NO: 1 **********************************************************************Create an application program for a post with the ability to take input from a student[ name, father’s name, date of birth(by using date picker) sex(option buttons),qualification(Using list box),address(Using Multiple text box),hobbies(check box)]use proper validation and display required messages. Store the valid information in a table and use data grid to view the inserted records.**********************************************************************Imports System.DataImports System.Data.SqlClientPublic Class Form1 Public inscmd1 As SqlCommand Public con As New SqlConnection("data source=PC2\SQLEXPRESS;initial catalog=BCA302;integrated security=true;") Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnexit.Click Me.Close() End Sub Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnclear.Click Txtstudname.Text = "" Txtfathername.Text = "" Txtregno.Text = "" Lstqual.Text = "" Rtbaddress.Text = "" Chbsinging.Text = "" Chbdancing.Text = "" Chbchess.Text = "" Chbreading.Text = "" Chbchating.Text = "" Chbwriting.Text = "" chbRiding.Text = "" rbnmale.Checked = False rbnfemale.Checked = False End Sub Private Sub Btninsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btninsert.Click Dim s As SqlCommand If Txtregno.Text = "" Or Txtstudname.Text = "" Or Txtfathername.Text = "" Or (rbnmale.Checked = False And rbnfemale.Checked = False) Or Lstqual.SelectedItem = "" Or Rtbaddress.Text = "" Then MsgBox("Enter All The Fields") End If Dim gender As String If rbnmale.Checked = True Then gender = rbnmale.Text Else gender = rbnfemale.Text End If Dim hobby As String hobby = " " If Chbsinging.Checked = True Then hobby = Chbsinging.Text End If If Chbdancing.Checked = True Then hobby = hobby & Chbdancing.Text End If If Chbchess.Checked = True Then hobby = hobby & Chbchess.Text End If If Chbreading.Checked = True Then hobby = hobby & Chbreading.Text End If If Chbchating.Checked = True Then hobby = hobby & Chbchating.Text End If If Chbwriting.Checked = True Then hobby = hobby & Chbwriting.Text End If If chbRiding.Checked = True Then hobby = hobby & chbRiding.Text End If Try con.Open() s = New SqlCommand("insert into student values('" & Txtregno.Text & "','" & Txtstudname.Text & "','" & Txtfathername.Text & "','" & gender & "','" & DateTimePicker1.Value & "','" & Lstqual.SelectedItem & "','" & Rtbaddress.Text & "','" & hobby & "')", con) s.ExecuteNonQuery() MsgBox("values added sucessfully", rmation, "student") con.Close() Catch ex As Exception MsgBox("Error") End Try End Sub Private Sub Btnview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnview.Click Dim ds As New DataSet Dim da As SqlDataAdapter da = New SqlDataAdapter("select * from student", con) da.Fill(ds, "student") DataGridView1.DataSource = ds.Tables("student").DefaultView End SubEnd ClassTable: StudentlefttopOUTPUT:EX.NO: 2 **********************************************************************Create a table TELEPHONE containing Telephone no, name and address of a customer as the fields. Set up a VB interface with command buttons to add, edit, delete, save, Use data controls. And view the records by clicking the data control.Apply validation rule telephone number to check for only +ve numeral.All the data are mandatory.Record should not be duplicated.When editing Telephone no. should not be modified.While editing or deleting, if the accepted Telephone no is not exist give proper message with confirming prompt delete.**********************************************************************Imports System.DataImports System.Data.SqlClient Public Class Form1 Public inscmd1 As SqlCommand Public con As New SqlConnection("data source=PC2\SQLEXPRESS;initial catalog=BCA302;integrated security=true;") Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click Dim no As Integer no = Val(Txtno.Text) If no < 0 Or (Asc(Txtno.Text) >= 65 And Asc(Txtno.Text) <= 90) Or (Asc(Txtno.Text) >= 97 And Asc(Txtno.Text) <= 122) Then MsgBox("number should not contain string or negative no") Txtno.Text = "" ElseIf Txtno.Text = "" And Txtname.Text = "" And Rtbaddress.Text = "" Then MsgBox("enter all the fields") Else con.Open() Dim namecommand As SqlCommand = New SqlCommand("select * from telephone where teleno='" & Txtno.Text & "'", con) Dim read As SqlDataReader = namecommand.ExecuteReader Do While (read.read()) MsgBox("info already exist in this no", rmation) read.Close() con.Close() Exit Sub Loop read.close() con.Close() con.Open() Dim s As SqlCommand s = New SqlCommand("insert into telephone values(" & Txtno.Text & ",'" & Txtname.Text & "','" & Rtbaddress.Text & "')", con) s.ExecuteNonQuery() MsgBox("VALUES ADDED SUCESSFULLY", rmation, "student") con.Close() End If End Sub Private Sub Btnedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnedit.Click loadcombo() Dim cmd As SqlCommand Dim s As String If Txtname.Text = "" Or Rtbaddress.Text = "" Then MsgBox("Enter Name A nd Address") End If If Btnedit.Text = "EDIT" Then Btnedit.Text = "SAVE" Else s = "update telephone set name='" & Txtname.Text & "',address='" & Rtbaddress.Text & "'where teleno=" & Txtno.Text & "" con.Open() cmd = New SqlCommand(s, con) cmd.ExecuteNonQuery() MsgBox("ONE ROW IS UPDATED") con.Close() Txtno.Show() Cmbtelno.Hide() Btnedit.Text = "EDIT" clear() End If End Sub Sub clear() Txtno.Text = "" Txtname.Text = "" Rtbaddress.Text = "" End Sub Private Sub Btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btndelete.Click Dim cmd As SqlCommand Dim s As String If Btndelete.Text = "DELETE" Then Btndelete.Text = "CONFIRM DELETE" loadcombo() Txtname.Hide() Rtbaddress.Hide() Label2.Hide() Label3.Hide() Else s = "delete from telephone where teleno=" & Cmbtelno.Text & "" con.Open() cmd = New SqlCommand(s, con) cmd.ExecuteNonQuery() MsgBox("ONE ROW IS DELETED") con.Close() Txtname.Show() Rtbaddress.Show() Label2.Show() Label3.Show() End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Cmbtelno.Hide() End Sub Sub loadcombo() Txtno.Hide() Cmbtelno.Show() Cmbtelno.Items.Clear() Try con.Open() Dim sc As SqlCommand = New SqlCommand("select * from telephone", con) Dim readsc As SqlDataReader = sc.ExecuteReader Do While (readsc.Read()) Cmbtelno.Items.Add(readsc.Item("teleno")) Loop readsc.Close() con.Close() Catch ex As Exception MsgBox("Error") End Try End SubEnd Class Table: TelephoneOUTPUT:EX.NO: 3 **********************************************************************Create a table EMP with Empcode, Name, Basic pay, DA, HRA, PF, Gross Tax and Net pay. Set up a data entry form to input empcode, name and salary. Other allowances should be calculated and to be shown on the form which can be modifiable. Use the command button for adding, saving, computing and various navigation (first record, next, previous, last.) use data control. (Don’t use data bound textboxes)All data are necessary while saving.Basic salary should be +ve numeric and name can contain alphabet and spaceWhile navigating if the control goes beyond beginning or end of the file display error message.DA is 40% if salary >20000 otherwise 30%, HRA=10% of salary.PF=12% of gross or Rs.780 whichever is minimum. Tax=10%.**********************************************************************Imports System.DataImports System.Data.SqlClient Public Class Form1 Dim bm As BindingManagerBase Public inscmd1 As SqlCommand Public con As New SqlConnection("data source=PC2\SQLEXPRESS;initial catalog=BCA302;integrated security=true;") Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnexit.Click Me.Close() End Sub Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click Txtno.Text = "" Txtname.Text = "" Txtsalary.Text = "" Txtda.Text = "" Txthra.Text = "" Txtpf.Text = "" Txttax.Text = "" Txtnetpay.Text = "" End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Btnadd.Enabled = False Btnfirst.Enabled = False Btnpvs.Enabled = False Btnnext.Enabled = False Btnlast.Enabled = False End Sub Private Sub Btncompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btncompute.Click If Txtno.Text = "" Or Txtname.Text = "" Or Txtsalary.Text = "" Then MsgBox("Enter All The Fields") ElseIf Txtsalary.Text <= 0 Then MsgBox("salary should not contain negative numbers", rmation) Else If (Asc(Txtname.Text) >= 65 And Asc(Txtname.Text) <= 90) Or (Asc(Txtname.Text) >= 97 And Asc(Txtname.Text) <= 122 Or Asc(Txtname.Text) = 32) Then Dim da, hra, pf, tax, grosspay, netpay As Integer Dim basicpay As Integer basicpay = CInt(Txtsalary.Text) If Txtsalary.Text <= 20000 Then da = (basicpay * 40) / 100 Else da = (basicpay * 30) / 100 End If hra = (basicpay * 10) / 100 grosspay = da + hra + basicpay pf = (grosspay * 10) / 100 If pf > 780 Then pf = 780 End If tax = (grosspay * 10) / 100 netpay = grosspay - (pf + tax) Txtda.Text = da Txthra.Text = hra Txtpf.Text = pf Txttax.Text = tax Txtnetpay.Text = netpay Btnadd.Enabled = True Btncompute.Enabled = True Else MsgBox("Name should contain alphabet and space") Txtname.Text = "" End If End If End Sub Private Sub Btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnadd.Click Try con.Open() Dim s As SqlCommand s = New SqlCommand("insert into employee values(" & Txtno.Text & ",'" & Txtname.Text & "','" & Txtsalary.Text & "','" & Txtda.Text & "','" & Txthra.Text & "','" & Txtpf.Text & "','" & Txttax.Text & "','" & Txtnetpay.Text & "')", con) s.ExecuteNonQuery() MsgBox("values added sucessfully", rmation, "employee") con.Close() Catch ex As Exception MsgBox("Error") End Try End Sub Private Sub Btnsb_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsb.Click Btnfirst.Enabled = True Btnpvs.Enabled = True Btnnext.Enabled = True Btnlast.Enabled = True Dim ds As New DataSet Dim da As SqlDataAdapter da = New SqlDataAdapter("select * from employee", con) da.Fill(ds, "employee") Txtno.DataBindings.Add(New Binding("text", ds, "employee.empno")) Txtname.DataBindings.Add(New Binding("text", ds, "employee.Name")) Txtsalary.DataBindings.Add(New Binding("text", ds, "employee.salary")) Txtda.DataBindings.Add(New Binding("text", ds, "employee.da")) Txthra.DataBindings.Add(New Binding("text", ds, "employee.hra")) Txtpf.DataBindings.Add(New Binding("text", ds, "employee.pf")) Txtnetpay.DataBindings.Add(New Binding("text", ds, "pay")) bm = Me.BindingContext(ds, "employee") bm.position = 0 Btnsb.Enabled = False End Sub Private Sub Btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnfirst.Click Dim ds As New DataSet bm.Position = 0 showposition() Btnfirst.Enabled = False Btnlast.Enabled = True End Sub Private Sub showposition() Lblstatus.Text = "Record" & bm.Position + 1 & "of" & bm.Count End Sub Private Sub Btnpvs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnpvs.Click Dim ds As New DataSet If bm.Position <= 0 Then MsgBox("First Record", MsgBoxStyle.Critical, "Error") Else bm.Position -= 1 showposition() End If End Sub Private Sub Btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnnext.Click Dim ds As New DataSet If bm.Position >= bm.Count - 1 Then MsgBox("Last Record", MsgBoxStyle.Critical, "Error") Else bm.Position += 1 showposition() End If End Sub Private Sub Btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnlast.Click Dim ds As New DataSet bm.Position = bm.Count - 1 showposition() Btnlast.Enabled = False Btnfirst.Enabled = True End SubEnd ClassTable: EmployeeOUTPUT:EX.NO: 4 ***********************************************************************Create a table item contains Item no, name, quantity in stock and unit price.Design a VB interface to enter he records and save to the table. Apply the validation rule for quantity and price for +ve numbers and non zero. Use the command buttons to navigate (first, next, prev, last) through the records depending on search criteria. Use data control.Searching can be By accepting item no.only the items with quantities>100Items either quantity less than 20 or unit price>=100To view all. While viewing it should not be editable.***********************************************************************Imports System.DataImports System.Data.SqlClientPublic Class form1 Dim bm As BindingManagerBase Public inscmd1 As SqlCommand Public con As New SqlConnection("data source=PC2\SQLEXPRESS;initial catalog=BCA302;integrated security=true;") Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnclear.Click clear() End Sub Sub clear() Txtno.Text = "" Txtname.Text = "" Txtqty.Text = "" Txtprice.Text = "" Txtno.DataBindings.Clear() Txtname.DataBindings.Clear() Txtqty.DataBindings.Clear() Txtprice.DataBindings.Clear() End Sub Private Sub Btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnadd.Click If Txtno.Text = "" Or Txtname.Text = "" Or Txtqty.Text = "" Or Txtprice.Text = "" Then MsgBox("Enter All The Fields") End If con.Open() Dim s As SqlCommand s = New SqlCommand("insert into item values(" & Txtno.Text & ",'" & Txtname.Text & "','" & Txtqty.Text & "','" & Txtprice.Text & "')", con) s.ExecuteNonQuery() MsgBox("values added sucessfully", rmation, "item") con.Close() End Sub Private Sub Btnfirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnfirst.Click Dim ds As New DataSet bm.Position = 0 showposition() Btnfirst.Enabled = False Btnlast.Enabled = True End Sub Private Sub showposition() Lblstatus.Text = "Record" & bm.Position + 1 & "of" & bm.Count End Sub Private Sub Btnpvs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnpvs.Click Dim ds As New DataSet If bm.Position <= 0 Then MsgBox("First Record", MsgBoxStyle.Critical, "Error") Else bm.Position -= 1 End If End Sub Private Sub Btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnnext.Click Dim ds As New DataSet If bm.Position >= bm.Count - 1 Then MsgBox("Last Record", MsgBoxStyle.Critical, "Error") Else bm.Position += 1 showposition() End If End Sub Private Sub Btnlast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnlast.Click 'Dim ds As DataSet bm.Position = bm.Count - 1 showposition() Btnlast.Enabled = False Btnfirst.Enabled = True End Sub Sub bind(ByVal s) clear() Btnfirst.Enabled = True Btnpvs.Enabled = True Btnnext.Enabled = True Btnlast.Enabled = True Try Dim ds As New DataSet Dim da As SqlDataAdapter da = New SqlDataAdapter(s, con) da.Fill(ds, "item") Txtno.DataBindings.Add(New Binding("text", ds, "item.itemno")) Txtname.DataBindings.Add(New Binding("text", ds, "item.Name")) Txtqty.DataBindings.Add(New Binding("text", ds, "item.quantity")) Txtprice.DataBindings.Add(New Binding("text", ds, "item.unitprice")) bm = Me.BindingContext(ds, "item") bm.Position = 0 Btnsb.Enabled = False Catch ex As Exception MsgBox("Error") End Try End Sub Private Sub RadioButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.Click Dim s As String Dim search As String search = InputBox("Enter Item No", "Item no") s = "select * from item where itemno='" & search & "'" bind(s) End Sub Private Sub RadioButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.Click Dim s As String s = "select * from Item where Quantity < 20 or unitprice >= 100" bind(s) End Sub Private Sub RadioButton3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton3.Click Dim s As String s = "select * from Item where Quantity >= 100" bind(s) End Sub Private Sub RadioButton4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton4.Click Dim s As String s = "select * from item" bind(s) End Sub End ClassTable: ItemOUTPUT: ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download