home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2002 September / PCPlus_193_Laplink2000.iso / Prog / vb / comm / Form1.vb < prev   
Encoding:
Text File  |  2002-04-29  |  13.3 KB  |  363 lines

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.  
  26.     'Required by the Windows Form Designer
  27.     Private components As System.ComponentModel.IContainer
  28.  
  29.     'NOTE: The following procedure is required by the Windows Form Designer
  30.     'It can be modified using the Windows Form Designer.  
  31.     'Do not modify it using the code editor.
  32.     Friend WithEvents TestComms As System.Windows.Forms.Button
  33.     Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
  34.     Friend WithEvents cc1 As comm.CommControl
  35.     Friend WithEvents cc2 As comm.CommControl
  36.     Friend WithEvents SetDTR1 As System.Windows.Forms.Button
  37.     Friend WithEvents SetDTR2 As System.Windows.Forms.Button
  38.     Friend WithEvents ClrDTR1 As System.Windows.Forms.Button
  39.     Friend WithEvents ClrDTR2 As System.Windows.Forms.Button
  40.     Friend WithEvents SetRTS1 As System.Windows.Forms.Button
  41.     Friend WithEvents SetRTS2 As System.Windows.Forms.Button
  42.     Friend WithEvents ClrRTS1 As System.Windows.Forms.Button
  43.     Friend WithEvents ClrRTS2 As System.Windows.Forms.Button
  44.     Friend WithEvents Button2 As System.Windows.Forms.Button
  45.     Friend WithEvents DSR1 As System.Windows.Forms.CheckBox
  46.     Friend WithEvents CTS1 As System.Windows.Forms.CheckBox
  47.     Friend WithEvents DSR2 As System.Windows.Forms.CheckBox
  48.     Friend WithEvents CTS2 As System.Windows.Forms.CheckBox
  49.     Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
  50.     Friend WithEvents Button1 As System.Windows.Forms.Button
  51.     Friend WithEvents Label1 As System.Windows.Forms.Label
  52.     Friend WithEvents Label2 As System.Windows.Forms.Label
  53.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  54.         Me.TestComms = New System.Windows.Forms.Button()
  55.         Me.cc1 = New comm.CommControl()
  56.         Me.TextBox1 = New System.Windows.Forms.TextBox()
  57.         Me.cc2 = New comm.CommControl()
  58.         Me.SetDTR1 = New System.Windows.Forms.Button()
  59.         Me.SetDTR2 = New System.Windows.Forms.Button()
  60.         Me.ClrDTR1 = New System.Windows.Forms.Button()
  61.         Me.ClrDTR2 = New System.Windows.Forms.Button()
  62.         Me.SetRTS1 = New System.Windows.Forms.Button()
  63.         Me.SetRTS2 = New System.Windows.Forms.Button()
  64.         Me.ClrRTS1 = New System.Windows.Forms.Button()
  65.         Me.ClrRTS2 = New System.Windows.Forms.Button()
  66.         Me.Button2 = New System.Windows.Forms.Button()
  67.         Me.DSR1 = New System.Windows.Forms.CheckBox()
  68.         Me.CTS1 = New System.Windows.Forms.CheckBox()
  69.         Me.DSR2 = New System.Windows.Forms.CheckBox()
  70.         Me.CTS2 = New System.Windows.Forms.CheckBox()
  71.         Me.TextBox2 = New System.Windows.Forms.TextBox()
  72.         Me.Button1 = New System.Windows.Forms.Button()
  73.         Me.Label1 = New System.Windows.Forms.Label()
  74.         Me.Label2 = New System.Windows.Forms.Label()
  75.         Me.SuspendLayout()
  76.         '
  77.         'TestComms
  78.         '
  79.         Me.TestComms.Location = New System.Drawing.Point(24, 8)
  80.         Me.TestComms.Name = "TestComms"
  81.         Me.TestComms.Size = New System.Drawing.Size(112, 32)
  82.         Me.TestComms.TabIndex = 2
  83.         Me.TestComms.Text = "Initialize"
  84.         '
  85.         'cc1
  86.         '
  87.         Me.cc1.Location = New System.Drawing.Point(648, 216)
  88.         Me.cc1.Name = "cc1"
  89.         Me.cc1.Size = New System.Drawing.Size(88, 40)
  90.         Me.cc1.TabIndex = 3
  91.         '
  92.         'TextBox1
  93.         '
  94.         Me.TextBox1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
  95.         Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  96.         Me.TextBox1.Location = New System.Drawing.Point(24, 320)
  97.         Me.TextBox1.Multiline = True
  98.         Me.TextBox1.Name = "TextBox1"
  99.         Me.TextBox1.ReadOnly = True
  100.         Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
  101.         Me.TextBox1.Size = New System.Drawing.Size(304, 192)
  102.         Me.TextBox1.TabIndex = 4
  103.         Me.TextBox1.Text = ""
  104.         '
  105.         'cc2
  106.         '
  107.         Me.cc2.Location = New System.Drawing.Point(640, 280)
  108.         Me.cc2.Name = "cc2"
  109.         Me.cc2.Size = New System.Drawing.Size(88, 40)
  110.         Me.cc2.TabIndex = 6
  111.         '
  112.         'SetDTR1
  113.         '
  114.         Me.SetDTR1.Location = New System.Drawing.Point(360, 32)
  115.         Me.SetDTR1.Name = "SetDTR1"
  116.         Me.SetDTR1.Size = New System.Drawing.Size(136, 32)
  117.         Me.SetDTR1.TabIndex = 7
  118.         Me.SetDTR1.Text = "Set DTR on Port 1"
  119.         '
  120.         'SetDTR2
  121.         '
  122.         Me.SetDTR2.Location = New System.Drawing.Point(360, 72)
  123.         Me.SetDTR2.Name = "SetDTR2"
  124.         Me.SetDTR2.Size = New System.Drawing.Size(136, 32)
  125.         Me.SetDTR2.TabIndex = 8
  126.         Me.SetDTR2.Text = "Set DTR on Port 2"
  127.         '
  128.         'ClrDTR1
  129.         '
  130.         Me.ClrDTR1.Location = New System.Drawing.Point(360, 112)
  131.         Me.ClrDTR1.Name = "ClrDTR1"
  132.         Me.ClrDTR1.Size = New System.Drawing.Size(136, 32)
  133.         Me.ClrDTR1.TabIndex = 9
  134.         Me.ClrDTR1.Text = "Clear DTR on Port 1"
  135.         '
  136.         'ClrDTR2
  137.         '
  138.         Me.ClrDTR2.Location = New System.Drawing.Point(360, 152)
  139.         Me.ClrDTR2.Name = "ClrDTR2"
  140.         Me.ClrDTR2.Size = New System.Drawing.Size(136, 32)
  141.         Me.ClrDTR2.TabIndex = 10
  142.         Me.ClrDTR2.Text = "Clear DTR on Port 2"
  143.         '
  144.         'SetRTS1
  145.         '
  146.         Me.SetRTS1.Location = New System.Drawing.Point(520, 32)
  147.         Me.SetRTS1.Name = "SetRTS1"
  148.         Me.SetRTS1.Size = New System.Drawing.Size(136, 32)
  149.         Me.SetRTS1.TabIndex = 11
  150.         Me.SetRTS1.Text = "Set RTS on Port 1"
  151.         '
  152.         'SetRTS2
  153.         '
  154.         Me.SetRTS2.Location = New System.Drawing.Point(520, 72)
  155.         Me.SetRTS2.Name = "SetRTS2"
  156.         Me.SetRTS2.Size = New System.Drawing.Size(136, 32)
  157.         Me.SetRTS2.TabIndex = 12
  158.         Me.SetRTS2.Text = "Set RTS on Port 2"
  159.         '
  160.         'ClrRTS1
  161.         '
  162.         Me.ClrRTS1.Location = New System.Drawing.Point(520, 112)
  163.         Me.ClrRTS1.Name = "ClrRTS1"
  164.         Me.ClrRTS1.Size = New System.Drawing.Size(136, 32)
  165.         Me.ClrRTS1.TabIndex = 13
  166.         Me.ClrRTS1.Text = "Clear RTS on Port 1"
  167.         '
  168.         'ClrRTS2
  169.         '
  170.         Me.ClrRTS2.Location = New System.Drawing.Point(520, 152)
  171.         Me.ClrRTS2.Name = "ClrRTS2"
  172.         Me.ClrRTS2.Size = New System.Drawing.Size(136, 32)
  173.         Me.ClrRTS2.TabIndex = 14
  174.         Me.ClrRTS2.Text = "Clear RTS on Port 2"
  175.         '
  176.         'Button2
  177.         '
  178.         Me.Button2.Location = New System.Drawing.Point(368, 352)
  179.         Me.Button2.Name = "Button2"
  180.         Me.Button2.Size = New System.Drawing.Size(192, 32)
  181.         Me.Button2.TabIndex = 15
  182.         Me.Button2.Text = "Check"
  183.         '
  184.         'DSR1
  185.         '
  186.         Me.DSR1.Location = New System.Drawing.Point(376, 280)
  187.         Me.DSR1.Name = "DSR1"
  188.         Me.DSR1.TabIndex = 16
  189.         Me.DSR1.Text = "DSR1"
  190.         '
  191.         'CTS1
  192.         '
  193.         Me.CTS1.Location = New System.Drawing.Point(376, 312)
  194.         Me.CTS1.Name = "CTS1"
  195.         Me.CTS1.TabIndex = 17
  196.         Me.CTS1.Text = "CTS1"
  197.         '
  198.         'DSR2
  199.         '
  200.         Me.DSR2.Location = New System.Drawing.Point(504, 280)
  201.         Me.DSR2.Name = "DSR2"
  202.         Me.DSR2.TabIndex = 18
  203.         Me.DSR2.Text = "DSR2"
  204.         '
  205.         'CTS2
  206.         '
  207.         Me.CTS2.Location = New System.Drawing.Point(504, 312)
  208.         Me.CTS2.Name = "CTS2"
  209.         Me.CTS2.TabIndex = 19
  210.         Me.CTS2.Text = "CTS2"
  211.         '
  212.         'TextBox2
  213.         '
  214.         Me.TextBox2.BackColor = System.Drawing.Color.FromArgb(CType(255, Byte), CType(192, Byte), CType(192, Byte))
  215.         Me.TextBox2.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  216.         Me.TextBox2.Location = New System.Drawing.Point(24, 72)
  217.         Me.TextBox2.Multiline = True
  218.         Me.TextBox2.Name = "TextBox2"
  219.         Me.TextBox2.ReadOnly = True
  220.         Me.TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
  221.         Me.TextBox2.Size = New System.Drawing.Size(304, 200)
  222.         Me.TextBox2.TabIndex = 20
  223.         Me.TextBox2.Text = ""
  224.         '
  225.         'Button1
  226.         '
  227.         Me.Button1.Location = New System.Drawing.Point(568, 352)
  228.         Me.Button1.Name = "Button1"
  229.         Me.Button1.Size = New System.Drawing.Size(192, 32)
  230.         Me.Button1.TabIndex = 21
  231.         Me.Button1.Text = "Write Test"
  232.         '
  233.         'Label1
  234.         '
  235.         Me.Label1.Location = New System.Drawing.Point(32, 48)
  236.         Me.Label1.Name = "Label1"
  237.         Me.Label1.Size = New System.Drawing.Size(136, 16)
  238.         Me.Label1.TabIndex = 22
  239.         Me.Label1.Text = "Received on port 2"
  240.         '
  241.         'Label2
  242.         '
  243.         Me.Label2.Location = New System.Drawing.Point(24, 296)
  244.         Me.Label2.Name = "Label2"
  245.         Me.Label2.Size = New System.Drawing.Size(136, 16)
  246.         Me.Label2.TabIndex = 23
  247.         Me.Label2.Text = "Received on port 1"
  248.         '
  249.         'Form1
  250.         '
  251.         Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
  252.         Me.ClientSize = New System.Drawing.Size(760, 536)
  253.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label2, Me.Label1, Me.Button1, Me.TextBox2, Me.CTS2, Me.DSR2, Me.CTS1, Me.DSR1, Me.Button2, Me.ClrRTS2, Me.ClrRTS1, Me.SetRTS2, Me.SetRTS1, Me.ClrDTR2, Me.ClrDTR1, Me.SetDTR2, Me.SetDTR1, Me.cc2, Me.TextBox1, Me.cc1, Me.TestComms})
  254.         Me.Name = "Form1"
  255.         Me.Text = "Form1"
  256.         Me.ResumeLayout(False)
  257.  
  258.     End Sub
  259.  
  260. #End Region
  261.  
  262.     Private Sub TestComms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestComms.Click
  263.  
  264.         cc1.OpenWithEvents(1, 9600)
  265.         cc2.OpenWithEvents(2, 9600)
  266.     End Sub
  267.  
  268.     Private Sub commevent1(ByVal m As Integer) Handles cc1.commEvent
  269.         Dim s As String
  270.         If m And cc1.EV_CTS Then
  271.             s += "1:CTS " + vbCrLf
  272.         End If
  273.         If m And cc1.EV_DSR Then
  274.             s += "1:DSR " + vbCrLf
  275.         End If
  276.         If m And cc1.EV_RING Then
  277.             s += "1:RI " + vbCrLf
  278.         End If
  279.         If m And cc1.EV_RLSD Then
  280.             s += "1:CD " + vbCrLf
  281.         End If
  282.         If m And cc1.EV_TXEMPTY Then
  283.             s += "1:TXEMPTY " + vbCrLf
  284.         End If
  285.         If m And cc1.EV_RXCHAR Then
  286.             s += "1:RX " + vbCrLf
  287.             s += cc2.Read + vbCrLf
  288.         End If
  289.         TextBox1.Text += s
  290.     End Sub
  291.  
  292.     Private Sub commevent2(ByVal m As Integer) Handles cc2.commEvent
  293.         Dim s As String
  294.  
  295.         If m And cc2.EV_CTS Then
  296.             s += "2:CTS " + vbCrLf
  297.         End If
  298.         If m And cc2.EV_DSR Then
  299.             s += "2:DSR " + vbCrLf
  300.         End If
  301.         If m And cc2.EV_RING Then
  302.             s += "2:RI " + vbCrLf
  303.         End If
  304.         If m And cc2.EV_RLSD Then
  305.             s += "2:CD " + vbCrLf
  306.         End If
  307.         If m And cc2.EV_TXEMPTY Then
  308.             s += "2:TXEMPTY " + vbCrLf
  309.         End If
  310.         If m And cc2.EV_RXCHAR Then
  311.             s += "2:RX " + vbCrLf
  312.             s += cc2.Read + vbCrLf
  313.         End If
  314.         TextBox2.Text += s
  315.     End Sub
  316.  
  317.     Private Sub SetDTR1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetDTR1.Click
  318.         cc1.DTR = True
  319.     End Sub
  320.  
  321.     Private Sub SetDTR2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetDTR2.Click
  322.         cc2.DTR = True
  323.     End Sub
  324.  
  325.     Private Sub ClrDTR1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClrDTR1.Click
  326.         cc1.DTR = False
  327.     End Sub
  328.  
  329.     Private Sub ClrDTR2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClrDTR2.Click
  330.         cc2.DTR = False
  331.     End Sub
  332.  
  333.     Private Sub SetRTS1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetRTS1.Click
  334.         cc1.RTS = True
  335.     End Sub
  336.  
  337.     Private Sub SetRTS2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetRTS2.Click
  338.         cc2.RTS = True
  339.     End Sub
  340.  
  341.     Private Sub ClrRTS1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClrRTS1.Click
  342.         cc1.RTS = False
  343.     End Sub
  344.  
  345.     Private Sub ClrRTS2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClrRTS2.Click
  346.         cc2.RTS = False
  347.     End Sub
  348.  
  349.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  350.  
  351.         CTS1.Checked = cc1.CTS
  352.         CTS2.Checked = cc2.CTS
  353.         DSR1.Checked = cc1.DSR
  354.         DSR2.Checked = cc2.DSR
  355.  
  356.     End Sub
  357.  
  358.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  359.         cc1.Write("hello, world")
  360.     End Sub
  361.  
  362. End Class
  363.