SHARE
TWEET

Untitled

a guest Apr 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Strict On
  2. Imports System.IO
  3. Imports System.Windows.Forms
  4.  
  5. Public Class ParentForm
  6.  
  7.     Dim counter As Integer = 0
  8.  
  9.     Private Sub NewToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles NewToolStripMenuItem.Click
  10.  
  11.         Dim NewChild As New ChildForm
  12.  
  13.         counter += 1
  14.  
  15.         NewChild.Text = "Window " & counter.ToString
  16.  
  17.         NewChild.MdiParent = Me
  18.  
  19.         NewChild.Show()
  20.  
  21.  
  22.     End Sub
  23.  
  24.     Private Sub OpenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles OpenToolStripMenuItem.Click
  25.  
  26.         Dim open As New OpenFileDialog
  27.  
  28.         open.ShowDialog()
  29.  
  30.         open.CheckFileExists = True
  31.  
  32.         Dim file1 As String
  33.  
  34.         file1 = open.FileName
  35.  
  36.         open.Title = "Open"
  37.  
  38.         open.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
  39.  
  40.         Dim sr As New StreamReader(file1)
  41.  
  42.  
  43.         Dim editor As New ChildForm()
  44.  
  45.         editor.MdiParent = Me
  46.  
  47.         editor.Show()
  48.  
  49.         editor.RichTextBox1.Text = sr.ReadToEnd()
  50.  
  51.         sr.Close()
  52.  
  53.     End Sub
  54.  
  55.     Private Sub SaveAsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveAsToolStripMenuItem.Click
  56.  
  57.  
  58.     End Sub
  59.  
  60.     Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
  61.  
  62.         Dim save As New SaveFileDialog()
  63.  
  64.         save.ShowDialog()
  65.  
  66.         save.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
  67.  
  68.         save.CheckPathExists = True
  69.  
  70.         Dim file1 As String
  71.  
  72.         file1 = save.FileName
  73.  
  74.         Dim sw As New StreamWriter(file1)
  75.  
  76.         Dim editor As New ChildForm()
  77.  
  78.         editor.MdiParent = Me
  79.  
  80.         editor.Show()
  81.  
  82.         sw.Write(editor.RichTextBox1.Text)
  83.  
  84.         sw.Close()
  85.  
  86.     End Sub
  87.  
  88.     Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
  89.  
  90.         Me.Close()
  91.  
  92.     End Sub
  93.  
  94.     Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CutToolStripMenuItem.Click
  95.  
  96.         Dim Form = Me.ActiveMdiChild
  97.  
  98.         If TypeOf Form.ActiveControl Is RichTextBox Then
  99.  
  100.             Dim Box As RichTextBox = DirectCast(Form.ActiveControl, RichTextBox)
  101.  
  102.             My.Computer.Clipboard.SetText(Box.SelectedText)
  103.  
  104.             Box.SelectedText = ""
  105.  
  106.         End If
  107.  
  108.     End Sub
  109.  
  110.     Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CopyToolStripMenuItem.Click
  111.  
  112.         Dim Form = Me.ActiveMdiChild
  113.  
  114.         Dim Box As RichTextBox = DirectCast(Form.ActiveControl, RichTextBox)
  115.  
  116.         My.Computer.Clipboard.SetText(Box.SelectedText)
  117.  
  118.     End Sub
  119.  
  120.     Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PasteToolStripMenuItem.Click
  121.  
  122.         Dim Form = Me.ActiveMdiChild
  123.  
  124.         Dim Box As RichTextBox = DirectCast(Form.ActiveControl, RichTextBox)
  125.  
  126.         Box.SelectedText = My.Computer.Clipboard.GetText
  127.  
  128.     End Sub
  129.  
  130.     Private Sub CascadeToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CascadeToolStripMenuItem.Click
  131.  
  132.         Me.LayoutMdi(MdiLayout.Cascade)
  133.  
  134.     End Sub
  135.  
  136.     Private Sub TileVerticalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
  137.  
  138.         Me.LayoutMdi(MdiLayout.TileVertical)
  139.  
  140.     End Sub
  141.  
  142.     Private Sub TileHorizontalToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
  143.  
  144.         Me.LayoutMdi(MdiLayout.TileHorizontal)
  145.  
  146.     End Sub
  147.  
  148.     Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
  149.  
  150.         MessageBox.Show("NETD2201" + vbNewLine + "LAB# 6" + vbNewLine + "Kush Gupta", "ABOUT")
  151.  
  152.     End Sub
  153.  
  154.     Private Sub ParentForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  155.  
  156.         Dim NewMDIChild As New ChildForm()
  157.  
  158.         NewMDIChild.MdiParent = Me
  159.  
  160.         NewMDIChild.Show()
  161.  
  162.     End Sub
  163.  
  164. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top