home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / vsflex / demo / ffind.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-30  |  5.0 KB  |  147 lines

  1. VERSION 2.00
  2. Begin Form fFind 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Find & Replace sample"
  6.    ClientHeight    =   3195
  7.    ClientLeft      =   330
  8.    ClientTop       =   1590
  9.    ClientWidth     =   5730
  10.    Height          =   3600
  11.    Left            =   270
  12.    LinkTopic       =   "Form3"
  13.    ScaleHeight     =   3195
  14.    ScaleWidth      =   5730
  15.    Top             =   1245
  16.    Width           =   5850
  17.    Begin vsFlexString fs 
  18.       Left            =   150
  19.       Pattern         =   "[^ ,    ]*"
  20.       Text            =   "VideoSoft FlexString"
  21.       Top             =   1680
  22.    End
  23.    Begin Frame Frame1 
  24.       BackColor       =   &H00C0C0C0&
  25.       Caption         =   "Find && Replace"
  26.       ForeColor       =   &H00800000&
  27.       Height          =   1035
  28.       Left            =   240
  29.       TabIndex        =   1
  30.       Top             =   2010
  31.       Width           =   5205
  32.       Begin TextBox Text1 
  33.          FontBold        =   0   'False
  34.          FontItalic      =   0   'False
  35.          FontName        =   "MS Sans Serif"
  36.          FontSize        =   8.25
  37.          FontStrikethru  =   0   'False
  38.          FontUnderline   =   0   'False
  39.          Height          =   285
  40.          Index           =   0
  41.          Left            =   1620
  42.          TabIndex        =   4
  43.          Text            =   "to {[^ ]+} find"
  44.          Top             =   240
  45.          Width           =   2100
  46.       End
  47.       Begin TextBox Text1 
  48.          FontBold        =   0   'False
  49.          FontItalic      =   0   'False
  50.          FontName        =   "MS Sans Serif"
  51.          FontSize        =   8.25
  52.          FontStrikethru  =   0   'False
  53.          FontUnderline   =   0   'False
  54.          Height          =   285
  55.          Index           =   1
  56.          Left            =   1620
  57.          TabIndex        =   3
  58.          Text            =   "to find {0}"
  59.          Top             =   600
  60.          Width           =   2100
  61.       End
  62.       Begin CommandButton Command1 
  63.          BackColor       =   &H00C0C0C0&
  64.          Caption         =   "Replace All"
  65.          FontBold        =   0   'False
  66.          FontItalic      =   0   'False
  67.          FontName        =   "MS Sans Serif"
  68.          FontSize        =   8.25
  69.          FontStrikethru  =   0   'False
  70.          FontUnderline   =   0   'False
  71.          Height          =   375
  72.          Index           =   0
  73.          Left            =   3855
  74.          TabIndex        =   2
  75.          Top             =   195
  76.          Width           =   1200
  77.       End
  78.       Begin Label Label1 
  79.          AutoSize        =   -1  'True
  80.          BackStyle       =   0  'Transparent
  81.          Caption         =   "Find What:"
  82.          FontBold        =   0   'False
  83.          FontItalic      =   0   'False
  84.          FontName        =   "MS Sans Serif"
  85.          FontSize        =   8.25
  86.          FontStrikethru  =   0   'False
  87.          FontUnderline   =   0   'False
  88.          Height          =   195
  89.          Index           =   0
  90.          Left            =   165
  91.          TabIndex        =   6
  92.          Top             =   345
  93.          Width           =   780
  94.       End
  95.       Begin Label Label1 
  96.          AutoSize        =   -1  'True
  97.          BackStyle       =   0  'Transparent
  98.          Caption         =   "Replace Width:"
  99.          FontBold        =   0   'False
  100.          FontItalic      =   0   'False
  101.          FontName        =   "MS Sans Serif"
  102.          FontSize        =   8.25
  103.          FontStrikethru  =   0   'False
  104.          FontUnderline   =   0   'False
  105.          Height          =   195
  106.          Index           =   1
  107.          Left            =   105
  108.          TabIndex        =   5
  109.          Top             =   615
  110.          Width           =   1110
  111.       End
  112.    End
  113.    Begin TextBox Text2 
  114.       FontBold        =   0   'False
  115.       FontItalic      =   0   'False
  116.       FontName        =   "MS Sans Serif"
  117.       FontSize        =   9.75
  118.       FontStrikethru  =   0   'False
  119.       FontUnderline   =   0   'False
  120.       Height          =   1680
  121.       Left            =   225
  122.       MultiLine       =   -1  'True
  123.       TabIndex        =   0
  124.       Text            =   "This is an example of how to use the FlexString control to automatically find and replace characters, words, or patterns in a textbox."
  125.       Top             =   180
  126.       Width           =   5160
  127.    End
  128. Option Explicit
  129. Sub Command1_Click (Index%)
  130.   Dim i%
  131.   ' --------------------------------------------------------------------
  132.   ' vsFlexString can automatically find and replace string within strings
  133.   ' --------------------------------------------------------------------
  134.   fs.Pattern = text1(0)   ' Find What
  135.   fs.Text = text2         ' Source
  136.   Select Case Index
  137.     Case 0  ' replace All
  138.       If fs.MatchCount > 0 Then
  139.      fs.Replace = text1(1)     ' Replace it with
  140.      text2 = fs
  141.      Beep
  142.       Else
  143.      MsgBox "Search text not found!"
  144.       End If
  145.   End Select
  146. End Sub
  147.