home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / termset.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  14.1 KB  |  472 lines

  1. VERSION 4.00
  2. Begin VB.Form ConfigScrn 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Communication Settings"
  5.    ClientHeight    =   3840
  6.    ClientLeft      =   735
  7.    ClientTop       =   1440
  8.    ClientWidth     =   4980
  9.    Height          =   4245
  10.    Icon            =   "TERMSET.frx":0000
  11.    Left            =   675
  12.    ScaleHeight     =   540
  13.    ScaleWidth      =   540
  14.    Top             =   1095
  15.    Width           =   5100
  16.    Begin VB.OptionButton ComPort 
  17.       Caption         =   "Com1"
  18.       Height          =   252
  19.       Index           =   1
  20.       Left            =   1920
  21.       TabIndex        =   31
  22.       Top             =   2340
  23.       Width           =   852
  24.    End
  25.    Begin VB.OptionButton ComPort 
  26.       Caption         =   "Com4"
  27.       Height          =   252
  28.       Index           =   4
  29.       Left            =   1920
  30.       TabIndex        =   30
  31.       Top             =   3240
  32.       Width           =   852
  33.    End
  34.    Begin VB.OptionButton ComPort 
  35.       Caption         =   "Com3"
  36.       Height          =   252
  37.       Index           =   3
  38.       Left            =   1920
  39.       TabIndex        =   29
  40.       Top             =   2940
  41.       Width           =   852
  42.    End
  43.    Begin VB.OptionButton ComPort 
  44.       Caption         =   "Com2"
  45.       Height          =   252
  46.       Index           =   2
  47.       Left            =   1920
  48.       TabIndex        =   28
  49.       Top             =   2640
  50.       Width           =   852
  51.    End
  52.    Begin VB.Frame Frame1 
  53.       Caption         =   "&Baud Rate"
  54.       Height          =   975
  55.       Left            =   240
  56.       TabIndex        =   2
  57.       Top             =   120
  58.       Width           =   3315
  59.       Begin VB.OptionButton Baud3 
  60.          Caption         =   "300"
  61.          Height          =   255
  62.          Left            =   300
  63.          TabIndex        =   3
  64.          Top             =   240
  65.          Width           =   735
  66.       End
  67.       Begin VB.OptionButton Baud6 
  68.          Caption         =   "600"
  69.          Height          =   255
  70.          Left            =   1260
  71.          TabIndex        =   4
  72.          Top             =   240
  73.          Width           =   615
  74.       End
  75.       Begin VB.OptionButton Baud12 
  76.          Caption         =   "1200"
  77.          Height          =   255
  78.          Left            =   2220
  79.          TabIndex        =   5
  80.          Top             =   240
  81.          Width           =   735
  82.       End
  83.       Begin VB.OptionButton Baud24 
  84.          Caption         =   "2400"
  85.          Height          =   255
  86.          Left            =   300
  87.          TabIndex        =   6
  88.          Top             =   600
  89.          Width           =   735
  90.       End
  91.       Begin VB.OptionButton Baud48 
  92.          Caption         =   "4800"
  93.          Height          =   255
  94.          Left            =   1260
  95.          TabIndex        =   7
  96.          Top             =   600
  97.          Width           =   735
  98.       End
  99.       Begin VB.OptionButton Baud96 
  100.          Caption         =   "9600"
  101.          Height          =   255
  102.          Left            =   2220
  103.          TabIndex        =   8
  104.          Top             =   600
  105.          Width           =   735
  106.       End
  107.    End
  108.    Begin VB.CommandButton OKButton 
  109.       Caption         =   "OK"
  110.       Default         =   -1  'True
  111.       Height          =   375
  112.       Left            =   3780
  113.       TabIndex        =   0
  114.       Top             =   240
  115.       Width           =   975
  116.    End
  117.    Begin VB.CommandButton CancelButton 
  118.       Cancel          =   -1  'True
  119.       Caption         =   "Cancel"
  120.       Height          =   375
  121.       Left            =   3780
  122.       TabIndex        =   1
  123.       Top             =   720
  124.       Width           =   975
  125.    End
  126.    Begin VB.Frame Frame2 
  127.       Caption         =   "&Data Bits"
  128.       Height          =   615
  129.       Left            =   240
  130.       TabIndex        =   9
  131.       Top             =   1260
  132.       Width           =   1275
  133.       Begin VB.OptionButton Data7 
  134.          Caption         =   "7"
  135.          Height          =   255
  136.          Left            =   180
  137.          TabIndex        =   10
  138.          Top             =   240
  139.          Width           =   375
  140.       End
  141.       Begin VB.OptionButton Data8 
  142.          Caption         =   "8"
  143.          Height          =   255
  144.          Left            =   720
  145.          TabIndex        =   11
  146.          Top             =   240
  147.          Width           =   435
  148.       End
  149.    End
  150.    Begin VB.Frame Frame3 
  151.       Caption         =   "&Stop Bits"
  152.       Height          =   615
  153.       Left            =   1740
  154.       TabIndex        =   12
  155.       Top             =   1260
  156.       Width           =   1335
  157.       Begin VB.OptionButton Stop1 
  158.          Caption         =   "1"
  159.          Height          =   255
  160.          Left            =   240
  161.          TabIndex        =   13
  162.          Top             =   240
  163.          Width           =   435
  164.       End
  165.       Begin VB.OptionButton Stop2 
  166.          Caption         =   "2"
  167.          Height          =   255
  168.          Left            =   780
  169.          TabIndex        =   14
  170.          Top             =   240
  171.          Width           =   495
  172.       End
  173.    End
  174.    Begin VB.Frame Frame7 
  175.       Caption         =   "&Echo"
  176.       Height          =   615
  177.       Left            =   3300
  178.       TabIndex        =   15
  179.       Top             =   1260
  180.       Width           =   1455
  181.       Begin VB.OptionButton EchoOff 
  182.          Caption         =   "Off"
  183.          Height          =   315
  184.          Left            =   780
  185.          TabIndex        =   17
  186.          Top             =   240
  187.          Width           =   615
  188.       End
  189.       Begin VB.OptionButton EchoOn 
  190.          Caption         =   "On"
  191.          Height          =   195
  192.          Left            =   180
  193.          TabIndex        =   16
  194.          Top             =   300
  195.          Width           =   555
  196.       End
  197.    End
  198.    Begin VB.Frame Frame4 
  199.       Caption         =   "&Parity"
  200.       Height          =   1575
  201.       Left            =   240
  202.       TabIndex        =   18
  203.       Top             =   2040
  204.       Width           =   1275
  205.       Begin VB.OptionButton NoParity 
  206.          Caption         =   "None"
  207.          Height          =   255
  208.          Left            =   180
  209.          TabIndex        =   19
  210.          Top             =   300
  211.          Width           =   855
  212.       End
  213.       Begin VB.OptionButton OddParity 
  214.          Caption         =   "Odd"
  215.          Height          =   255
  216.          Left            =   180
  217.          TabIndex        =   20
  218.          Top             =   600
  219.          Width           =   735
  220.       End
  221.       Begin VB.OptionButton EvenParity 
  222.          Caption         =   "Even"
  223.          Height          =   255
  224.          Left            =   180
  225.          TabIndex        =   21
  226.          Top             =   900
  227.          Width           =   855
  228.       End
  229.    End
  230.    Begin VB.Frame Frame6 
  231.       Caption         =   "&Com Port"
  232.       Height          =   1575
  233.       Left            =   1740
  234.       TabIndex        =   22
  235.       Top             =   2040
  236.       Width           =   1335
  237.    End
  238.    Begin VB.Frame Frame5 
  239.       Caption         =   "&Flow Control"
  240.       Height          =   1575
  241.       Left            =   3300
  242.       TabIndex        =   23
  243.       Top             =   2040
  244.       Width           =   1455
  245.       Begin VB.OptionButton NoFlow 
  246.          Caption         =   "None"
  247.          Height          =   255
  248.          Left            =   180
  249.          TabIndex        =   26
  250.          Top             =   300
  251.          Width           =   855
  252.       End
  253.       Begin VB.OptionButton XonFlow 
  254.          Caption         =   "Xon/Xoff"
  255.          Height          =   255
  256.          Left            =   180
  257.          TabIndex        =   24
  258.          Top             =   600
  259.          Width           =   1095
  260.       End
  261.       Begin VB.OptionButton RTSFlow 
  262.          Caption         =   "RTS"
  263.          Height          =   255
  264.          Left            =   180
  265.          TabIndex        =   25
  266.          Top             =   900
  267.          Width           =   735
  268.       End
  269.       Begin VB.OptionButton BothFlow 
  270.          Caption         =   "Xon/RTS"
  271.          Height          =   255
  272.          Left            =   180
  273.          TabIndex        =   27
  274.          Top             =   1200
  275.          Width           =   1155
  276.       End
  277.    End
  278. Attribute VB_Name = "ConfigScrn"
  279. Attribute VB_Creatable = False
  280. Attribute VB_Exposed = False
  281. ' Communication Settings Configuration Form
  282. ' Copyright (c) 1994, Crescent Software
  283. DefInt A-Z
  284. Dim Shared NewPort                 ' Temporary configuration settings.
  285. Dim Shared NewBaud$, NewParity$
  286. Dim Shared NewData$, NewStop$
  287. Dim Shared NewShake
  288. ' 1200 baud option button.
  289. Private Sub Baud12_Click()
  290.     NewBaud$ = "1200"
  291. End Sub
  292. ' 2400 baud option button.
  293. Private Sub Baud24_Click()
  294.     NewBaud$ = "2400"
  295. End Sub
  296. ' 300 baud option button.
  297. Private Sub Baud3_Click()
  298.     NewBaud$ = "300"
  299. End Sub
  300. ' 4800 baud option button.
  301. Private Sub Baud48_Click()
  302.     NewBaud$ = "4800"
  303. End Sub
  304. ' 600 baud option button.
  305. Private Sub Baud6_Click()
  306.     NewBaud$ = "600"
  307. End Sub
  308. ' 9600 baud option button.
  309. Private Sub Baud96_Click()
  310.     NewBaud$ = "9600"
  311. End Sub
  312. ' Both RTS and Xon/Xoff handshaking option button.
  313. Private Sub BothFlow_Click()
  314.     NewShake = 3
  315. End Sub
  316. ' Cancel button actions.
  317. Private Sub CancelButton_Click()
  318.     Unload ConfigScrn
  319. End Sub
  320. Private Sub ComPort_Click(Index As Integer)
  321.     NewPort = Index
  322. End Sub
  323. ' 7 data bits option button.
  324. Private Sub Data7_Click()
  325.     NewData$ = "7"
  326. End Sub
  327. ' 8 data bits option button.
  328. Private Sub Data8_Click()
  329.     NewData$ = "8"
  330. End Sub
  331. ' Echo Off option button.
  332. Private Sub EchoOff_Click()
  333.     Echo = 0
  334. End Sub
  335. ' Echo On option button.
  336. Private Sub EchoOn_Click()
  337.     Echo = True
  338. End Sub
  339. ' Even Parity option button.
  340. Private Sub EvenParity_Click()
  341.     NewParity$ = "E"
  342. End Sub
  343. ' Initialize and display the configuration form.
  344. Private Sub Form_Load()
  345.     ' Get the current port.
  346.     Port = Form1.MSComm1.CommPort
  347.     ConfigScrn.ComPort(Port).VALUE = True   ' Set the option button.
  348.     ' Get the current baud.
  349.     FirstComma = InStr(Form1.MSComm1.Settings, ",")
  350.     Baud$ = Left(Form1.MSComm1.Settings, FirstComma - 1)
  351.     Select Case Val(Baud$)                  ' Select baud.
  352.     Case 300                                ' Set the active baud option button.
  353.         ConfigScrn.Baud3.VALUE = True
  354.     Case 600
  355.         ConfigScrn.Baud6.VALUE = True
  356.     Case 1200
  357.         ConfigScrn.Baud12.VALUE = True
  358.     Case 2400
  359.         ConfigScrn.Baud24.VALUE = True
  360.     Case 4800
  361.         ConfigScrn.Baud48.VALUE = True
  362.     Case 9600
  363.         ConfigScrn.Baud96.VALUE = True
  364.     End Select
  365.     ' Get the current parity.
  366.     Parity$ = Mid$(Form1.MSComm1.Settings, FirstComma + 1, 1)
  367.     Select Case UCase$(Parity$)              ' Select parity.
  368.     Case "N"                                 ' Set the active parity option button.
  369.         ConfigScrn.NoParity.VALUE = True
  370.     Case "E"
  371.         ConfigScrn.EvenParity.VALUE = True
  372.     Case "O"
  373.         ConfigScrn.OddParity.VALUE = True
  374.     End Select
  375.     ' Get the data bits.
  376.     SecondComma = FirstComma + 2
  377.     DBits$ = Mid$(Form1.MSComm1.Settings, SecondComma + 1, 1)
  378.     Select Case Val(DBits$)                 ' Select data bits.
  379.     Case 7                                  ' Set the active choice option button.
  380.         ConfigScrn.Data7.VALUE = True
  381.     Case 8
  382.         ConfigScrn.Data8.VALUE = True
  383.     End Select
  384.     ' Get the stop bits.
  385.     ThirdComma = SecondComma + 2
  386.     SBits$ = Mid$(Form1.MSComm1.Settings, ThirdComma + 1, 1)
  387.     Select Case Val(SBits$)                 ' Select stop bits.
  388.     Case 1                                  ' Set the active choice option button.
  389.         ConfigScrn.Stop1.VALUE = True
  390.     Case 2
  391.         ConfigScrn.Stop2.VALUE = True
  392.     End Select
  393.     Select Case Form1.MSComm1.Handshaking
  394.     Case 0                                  ' Set active choice option button.
  395.         ConfigScrn.NoFlow.VALUE = True
  396.     Case 1
  397.         ConfigScrn.XonFlow.VALUE = True
  398.     Case 2
  399.         ConfigScrn.RTSFlow.VALUE = True
  400.     Case 3
  401.         ConfigScrn.BothFlow.VALUE = True
  402.     End Select
  403.     If Echo Then
  404.         ConfigScrn.EchoOn.VALUE = True
  405.     Else
  406.         ConfigScrn.EchoOff.VALUE = True
  407.     End If
  408. End Sub
  409. ' No handshaking option button.
  410. Private Sub NoFlow_Click()
  411.     NewShake = 0
  412. End Sub
  413. ' No Parity option button.
  414. Private Sub NoParity_Click()
  415.     NewParity$ = "N"
  416. End Sub
  417. ' Odd Parity option button.
  418. Private Sub OddParity_Click()
  419.     NewParity$ = "O"
  420. End Sub
  421. ' OK button actions.
  422. Private Sub OkButton_Click()
  423.     On Error Resume Next
  424.     OldPort = Form1.MSComm1.CommPort
  425.     If NewPort <> OldPort Then                    ' If the port number changes, close the old port.
  426.         If Form1.MSComm1.PortOpen Then
  427.            Form1.MSComm1.PortOpen = False
  428.            ReOpen = True
  429.         End If
  430.         Form1.MSComm1.CommPort = NewPort          ' Set the new port number.
  431.         If Err = 0 Then
  432.            If ReOpen Then
  433.               Form1.MSComm1.PortOpen = True
  434.               Form1.MOpen.Checked = Form1.MSComm1.PortOpen
  435.               Form1.MSendText.Enabled = Form1.MSComm1.PortOpen
  436.            End If
  437.         End If
  438.         If Err Then
  439.            MsgBox Error$, 48
  440.            Form1.MSComm1.CommPort = OldPort
  441.            Exit Sub
  442.         End If
  443.     End If
  444.     Form1.MSComm1.Settings = NewBaud$ + "," + NewParity$ + "," + NewData$ + "," + NewStop$
  445.     If Err Then
  446.        MsgBox Error$, 48
  447.        Exit Sub
  448.     End If
  449.     Form1.MSComm1.Handshaking = NewShake
  450.     If Err Then
  451.        MsgBox Error$, 48
  452.        Exit Sub
  453.     End If
  454.     Unload ConfigScrn                               ' Unload the configuration form.
  455. End Sub
  456. ' RTS handshaking option button.
  457. Private Sub RTSFlow_Click()
  458.     NewShake = 2
  459. End Sub
  460. ' 1 stop bit option button.
  461. Private Sub Stop1_Click()
  462.     NewStop$ = "1"
  463. End Sub
  464. ' 2 stop bits option button.
  465. Private Sub Stop2_Click()
  466.     NewStop$ = "2"
  467. End Sub
  468. ' XON handshaking option button.
  469. Private Sub XonFlow_Click()
  470.     NewShake = 1
  471. End Sub
  472.