VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text3 
      Height          =   435
      Left            =   660
      TabIndex        =   3
      Text            =   "6.0"
      Top             =   1860
      Width           =   2625
   End
   Begin VB.TextBox Text2 
      Height          =   435
      Left            =   690
      TabIndex        =   2
      Text            =   "5.0"
      Top             =   1320
      Width           =   2625
   End
   Begin VB.TextBox Text1 
      Height          =   435
      Left            =   690
      TabIndex        =   1
      Text            =   "Visual Basic 程序设计教程5.0版"
      Top             =   780
      Width           =   3735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   2040
      TabIndex        =   0
      Top             =   2640
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "替换为"
      Height          =   375
      Index           =   2
      Left            =   60
      TabIndex        =   6
      Top             =   1920
      Width           =   645
   End
   Begin VB.Label Label1 
      Caption         =   "查找"
      Height          =   375
      Index           =   1
      Left            =   60
      TabIndex        =   5
      Top             =   1440
      Width           =   645
   End
   Begin VB.Label Label1 
      Caption         =   "内容"
      Height          =   375
      Index           =   0
      Left            =   60
      TabIndex        =   4
      Top             =   840
      Width           =   645
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Public Function MyReplace(s$, OldS$, NewS$) As String
  Dim i%, lenOldS%
  lenOldS = Len(OldS)
  i = InStr(s, OldS)
  Do While i > 0
    s = Left(s, i - 1) + NewS + Mid(s, i + lenOldS)
    i = InStr(s, OldS)
  Loop
  MyReplace = s
End Function

Private Sub Command1_Click()
   Print MyReplace(Text1, Text2, Text3)
End Sub
Public Sub sMyReplace(s$, OldS$, NewS$)
  Dim i%, lenOldS%
  lenOldS = Len(OldS)
  i = InStr(s, OldS)
  Do While i > 0
    s = Left(s, i - 1) + NewS + Mid(s, i + lenOldS)
    i = InStr(s, OldS)
  Loop
End Sub

