home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / inter / webster.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-08  |  4.3 KB  |  145 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Webster's Dictionary"
  5.    ClientHeight    =   4545
  6.    ClientLeft      =   630
  7.    ClientTop       =   1875
  8.    ClientWidth     =   9405
  9.    Height          =   4950
  10.    Icon            =   WEBSTER.FRX:0000
  11.    Left            =   570
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4545
  14.    ScaleWidth      =   9405
  15.    Top             =   1530
  16.    Width           =   9525
  17.    Begin CommandButton btnDone 
  18.       Cancel          =   -1  'True
  19.       Caption         =   "Done"
  20.       Height          =   375
  21.       Left            =   90
  22.       TabIndex        =   4
  23.       Top             =   4095
  24.       Width           =   1050
  25.    End
  26.    Begin CommandButton btnDefine 
  27.       Caption         =   "Define"
  28.       Default         =   -1  'True
  29.       Height          =   375
  30.       Left            =   7920
  31.       TabIndex        =   3
  32.       Top             =   45
  33.       Width           =   1365
  34.    End
  35.    Begin TextBox txtWord 
  36.       FontBold        =   0   'False
  37.       FontItalic      =   0   'False
  38.       FontName        =   "MS Sans Serif"
  39.       FontSize        =   9.75
  40.       FontStrikethru  =   0   'False
  41.       FontUnderline   =   0   'False
  42.       Height          =   360
  43.       Left            =   675
  44.       TabIndex        =   0
  45.       Top             =   90
  46.       Width           =   4245
  47.    End
  48.    Begin TextBox txtDesc 
  49.       FontBold        =   0   'False
  50.       FontItalic      =   0   'False
  51.       FontName        =   "MS Sans Serif"
  52.       FontSize        =   9.75
  53.       FontStrikethru  =   0   'False
  54.       FontUnderline   =   0   'False
  55.       Height          =   3480
  56.       Left            =   90
  57.       MultiLine       =   -1  'True
  58.       ScrollBars      =   2  'Vertical
  59.       TabIndex        =   1
  60.       Top             =   540
  61.       Width           =   9195
  62.    End
  63.    Begin dsSocket dsSocket1 
  64.       DataSize        =   2048
  65.       Left            =   1305
  66.       Linger          =   0   'False
  67.       LocalPort       =   0
  68.       RemoteDotAddr   =   ""
  69.       RemoteHost      =   ""
  70.       RemotePort      =   0
  71.       ServiceName     =   ""
  72.       Timeout         =   0
  73.       Top             =   4095
  74.    End
  75.    Begin Label Label1 
  76.       AutoSize        =   -1  'True
  77.       Caption         =   "Word:"
  78.       Height          =   195
  79.       Left            =   90
  80.       TabIndex        =   2
  81.       Top             =   135
  82.       Width           =   525
  83.    End
  84. DefInt A-Z
  85. Dim Connected
  86. Sub btnDefine_Click ()
  87.     On Error GoTo ConnectError:
  88.     '-- Clear the description
  89.     txtDesc = ""
  90.     '-- Are we already connected?
  91.     If dsSocket1.Socket = 0 Then
  92.         '-- No. Connect to the Webster Server
  93.         dsSocket1.RemotePort = 2627
  94.         dsSocket1.RemoteHost = "grouchy.cs.indiana.edu"
  95.         '-- Connect
  96.         dsSocket1.Action = DSSOCK_CONNECT
  97.         '-- Temporarily disable the txtWord field
  98.         txtWord.Enabled = False
  99.         Screen.MousePointer = 11
  100.         '-- Wait until we've connected
  101.         Do
  102.             DoEvents
  103.         Loop Until Connected
  104.     End If
  105.     '-- Send the definition request
  106.     dsSocket1.Send = "DEFINE " & txtWord & Chr$(10)
  107.     Exit Sub
  108. ConnectError:
  109.     MsgBox Error
  110. End Sub
  111. Sub btnDone_Click ()
  112.     '-- Unload the form
  113.     Unload Me
  114. End Sub
  115. Sub dsSocket1_Connect ()
  116.     '-- Set the Connect flag to True.
  117.     Connected = True
  118. End Sub
  119. Sub dsSocket1_Exception (ErrorCode As Integer, ErrorDesc As String)
  120. '-- An exception (error) has occurred
  121.     If ErrorCode = 0 Then
  122.         '-- We were disconnected
  123.         Connected = False
  124.     End If
  125.     MsgBox ErrorDesc
  126. End Sub
  127. Sub dsSocket1_Receive (receiveData As String)
  128.     '-- Data has been received by sockets
  129.     '-- Add this data to the description
  130.     txtDesc = txtDesc & Left$(receiveData, Len(receiveData) - 1)
  131.     '-- Re-enable and clear the word field, and
  132.     '   set focus to it.
  133.     Screen.MousePointer = 0
  134.     txtWord.Enabled = True
  135.     txtWord = ""
  136.     txtWord.SetFocus
  137. End Sub
  138. Sub Form_Unload (Cancel As Integer)
  139.     '-- Close any open connection (very important)
  140.     If dsSocket1.Socket Then
  141.         dsSocket1.Action = DSSOCK_CLOSE
  142.     End If
  143.     End
  144. End Sub
  145.