BAPATLA Department of MCA 1 Dot Net
Total Page:16
File Type:pdf, Size:1020Kb
BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA VB.NET 1.Develop an application which is similar to notepad using menus. Code: 1. Create a new Window application with name as notepad 2. Add Menu Strip to form1 and set IsMdiContainer property of form1 to true 3. Set text property of form1 as Notepad 4. Create File menu by adding text at type here textbox.(File,New ,Open,save,Exit) 5. Create Edit menu by adding text at type here textbox.(Edit,cut,Copy,Paste,Select All,Time/date,Clear) 6. Create Format menu by adding text at type here textbox.(Format,font) 7. Add Form2 tp project by clicking Project menu. 8. Add Richtextbox to form2 and set dock property of richtextbox to fill. 9. Add the following code by double clicking File-New Option in menustrip. 10. Add OpenfileDialog,SaveFileDialog,FontDialog to form1. Public Class Form1 Dim n As Integer Dim forms(10) As Form2 Dim s As String Dim s1 As Integer Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click n += 1 forms(n) = New Form2 forms(n).Text = "Unititled document" & Str(n) 1 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA forms(n).MdiParent = Me forms(n).Show() End Sub ////// Double click on File-Open option in menu Strip and add the code. Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click OpenFileDialog1.Filter = "txtfile(*.txt*)|*.txt*" If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then forms(n).Show() forms(n).RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName) forms(n).Text = OpenFileDialog1.FileName End If End Sub ////// Double click on File-Save option in menu Strip and add the code. Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click s = forms(n).RichTextBox1.Text SaveFileDialog1.Filter = "txtfiles(*.txt*)|*.txt*" SaveFileDialog1.Title = "save " If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then My.Computer.FileSystem.WriteAllText(SaveFileDialog1.FileName, s, True) forms(n).Text = SaveFileDialog1.FileName forms(n).RichTextBox1.Text = s End If End Sub ////// Double click on File-Close option in menu Strip and add the code. 2 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click End End Sub ////// Double click on Edit-Cut option in menu Strip and add the code. Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click forms(n).RichTextBox1.Select() forms(n).RichTextBox1.Cut() End Sub ////// Double click on Edit-Copy option in menu Strip and add the code. Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click forms(n).RichTextBox1.Select() forms(n).RichTextBox1.Copy() End Sub ////// Double click on Edit-Paste option in menu Strip and add the code. Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click forms(n).RichTextBox1.Paste() End Sub ////// Double click on Edit-SelectAll option in menu Strip and add the code. Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click forms(n).RichTextBox1.SelectAll() 3 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA End Sub ////// Double click on Edit-Clear option in menu Strip and add the code. Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click forms(n).RichTextBox1.Clear() End Sub ////// Double click on Edit-Time/Date option in menu Strip and add the code. Private Sub TimedateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimedateToolStripMenuItem.Click forms(n).RichTextBox1.Text = Date.Today.ToString End Sub ////// Double click on Format-Font option in menu Strip and add the code. Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click If FontDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then forms(n).RichTextBox1.ForeColor = FontDialog1.Color forms(n).RichTextBox1.Font = FontDialog1.Font End If End Sub End Class 4 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA Design: Title of the form: Notepad Controls used: Control Name Caption Form1 Notepad Form2 Form2 MenuStrip Menustrip1 OpenFileDialog OpenFileDialog1 SaveFileDialog SaveFileDialog1 FontDialog FontDialog1 Richtextbox1 Richtextbox1 2.a) Develop an application for facilitating purchasing order . 5 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA Code: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cmb_cars.Items.Add("car1") cmb_cars.Items.Add("car2") cmb_cars.Items.Add("car3") cmb_cars.Text = "Select One" End Sub Private Sub cmb_cars_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cmb_cars.SelectedIndexChanged lst_model.Items.Clear() txt_price.Clear() cmb_colors.Items.Clear() cmb_colors.Text = "select One" Dim str As String = cmb_cars.SelectedItem.ToString() MsgBox(str) If str = "car1" Then cmb_colors.Items.Add("red") cmb_colors.Items.Add("blue") cmb_colors.Items.Add("Black") lst_model.Items.Add("Model1") lst_model.Items.Add("Model2") lst_model.Items.Add("Model3") ElseIf cmb_cars.SelectedItem.ToString() = "car2" Then 6 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA cmb_colors.Items.Add("White") cmb_colors.Items.Add("Silver") cmb_colors.Items.Add("Black") lst_model.Items.Add("Model4") lst_model.Items.Add("Model5") lst_model.Items.Add("Model6") ElseIf cmb_cars.SelectedItem.ToString() = "car3" Then cmb_colors.Items.Add("Darkgreen") cmb_colors.Items.Add("green") cmb_colors.Items.Add("Black") lst_model.Items.Add("Model7") lst_model.Items.Add("Model8") lst_model.Items.Add("Model9") End If End Sub Private Sub lst_model_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_model.SelectedIndexChanged Dim str As String = lst_model.SelectedItem.ToString() If str = "Model1" Or str = "Model4" Or str = "Model7" Then txt_price.Text = "4,00000" ElseIf str = "Model2" Or str = "Model5" Or str = "Model8" Then txt_price.Text = "3,50000" ElseIf str = "Model3" Or str = "Model6" Or str = "Model9" Then txt_price.Text = "6,00000" End If End Sub 7 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA Private Sub btn_purchase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_purchase.Click MessageBox.Show("Thank for purchasing" & Cmb_cars.SelectedItem.ToString()) End Sub End Class Design: Title of the form: Purchase Car Controls used: Control Name Text Form1 form1 Purchase car Label1 lbl_title Purchase car Label2 lbl_cars Cars Label3 lbl_colors Colors Label4 lbl_model Model Label5 lbl_price Price in Rs Button1 btn_purchase Purchase Button2 btn_cancel Cancel Combobox1 cmb_cars Select one Combobox2 cmb_colors Select One List box lst_model Textbox1 txt_price b). Develop an application for billing system in coffee shop 8 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA Code: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load lbl_cardno.Visible = False txt_card.Visible = False End Sub Private Sub btn_calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_calculate.Click Dim ws, wos, cc, hc, tc, tt, tot As Integer ws = 5 wos = 8 cc = 20 hc = 10 If chk_tea.Checked = True Then tt = txt_tea.Text * wos ElseIf chk_tea.Checked = False Then tt = txt_tea.Text * ws End If 9 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA If chk_coffee.Checked = True Then tc = txt_coffee.Text * cc ElseIf chk_coffee.Checked = False Then tc = txt_coffee.Text * hc End If tot = tt + tc If rdo_cash.Checked = True Then txt_amt.Text = tot MsgBox("Payment received in Cash!Thank U u select" & chk_tea.Text & "and " & chk_coffee.Text) ElseIf rdo_card.Checked = True Then If txt_card.Text = "" Then MsgBox("U must enter pin number") txt_card.Focus() Else txt_card.Text = tot MsgBox("Payment is deduced from ur account") End If ElseIf rdo_cash.Checked = False And Rdo_card.Checked = False Then MsgBox("U must choose payment mode") End If End Sub Private Sub rdo_card_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdo_card.CheckedChanged lbl_cardno.Visible = True txt_card.Visible = True 10 Dot Net Programming Lab Manual (MCA 506) BAPATLA ENGINEERING COLLEGE: BAPATLA Department of MCA End Sub Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click Me.Close() End Sub End Class Design: Title of the form: Cafeteria Controls used: Control Name Text Form1 Form1 Cafeteria Label1 lbl_tea Tea Label2