VERSION 5.00 Begin VB.Form frmBuscar BorderStyle = 3 'Fixed Dialog Caption = "Buscar" ClientHeight = 2115 ClientLeft = 45 ClientTop = 330 ClientWidth = 6795 Icon = "Buscar.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 2115 ScaleWidth = 6795 ShowInTaskbar = 0 'False StartUpPosition = 1 'CenterOwner Begin VB.CommandButton cmdReemplazarTodo Caption = "Reemplazar &todo" Height = 375 Left = 5160 TabIndex = 5 Top = 1680 Width = 1575 End Begin VB.CommandButton cmdReemplazar Caption = "&Reemplazar" Height = 375 Left = 5160 TabIndex = 4 Top = 1200 Width = 1575 End Begin VB.TextBox txtReemplazar Height = 285 Left = 1440 TabIndex = 1 Top = 480 Width = 3615 End Begin VB.CommandButton cmdCancelar Cancel = -1 'True Caption = "&Cancelar" Height = 375 Left = 5160 TabIndex = 3 Top = 600 Width = 1575 End Begin VB.CommandButton cmdBuscar Caption = "Buscar &siguiente" Default = -1 'True Enabled = 0 'False Height = 375 Left = 5160 TabIndex = 2 Top = 120 Width = 1575 End Begin VB.CheckBox chkMayMin Caption = "Coi&ncidir mayúsculas/minúsculas" Height = 255 Left = 1440 TabIndex = 6 Top = 840 Width = 3135 End Begin VB.TextBox txtBuscar Height = 285 Left = 1440 TabIndex = 0 Top = 120 Width = 3615 End Begin VB.Label lblReemplazar Caption = "Reemplazar con:" Height = 255 Left = 120 TabIndex = 8 Top = 480 Width = 1215 End Begin VB.Label lblBuscar Caption = "Buscar:" Height = 255 Left = 120 TabIndex = 7 Top = 120 Width = 1335 End End Attribute VB_Name = "frmBuscar" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private bReemplazar As Boolean Private Sub cmdBuscar_Click() Dim lPos As Long On Error Resume Next ' empezamos la búsqueda en el carácter siguiente al que nos encontramos lPos = InStr(frmProc.txtEditor.SelStart + 2, frmProc.txtEditor.Text, txtBuscar.Text, _ IIf(chkMayMin.Value, vbBinaryCompare, vbTextCompare)) If lPos > 0 Then frmProc.txtEditor.SelStart = lPos - 1 frmProc.txtEditor.SelLength = Len(txtBuscar.Text) Me.Hide Else MsgBox "Búsqueda finalizada.", vbOKOnly + vbInformation, "Buscar" End If End Sub Private Sub cmdCancelar_Click() Me.Hide End Sub Public Sub BuscarSgte() If txtBuscar.Text <> "" Then cmdBuscar_Click Else Me.Show vbModal End If End Sub Private Sub cmdReemplazar_Click() If frmProc.txtEditor.SelLength > 0 Then frmProc.txtEditor.SelText = txtReemplazar.Text End If End Sub Private Sub cmdReemplazarTodo_Click() Dim iOpc As Integer iOpc = MsgBox("Se van a reemplazar todas las apariciones del texto. ¿Quieres continuar?", _ vbYesNo + vbQuestion, "Reemplazar") If iOpc <> vbYes Then Exit Sub End If Screen.MousePointer = vbHourglass frmProc.txtEditor.Text = Replace(frmProc.txtEditor.Text, txtBuscar.Text, txtReemplazar.Text, 1, -1, _ IIf(chkMayMin.Value, vbBinaryCompare, vbTextCompare)) Screen.MousePointer = vbDefault End Sub Private Sub Form_Load() bReemplazar = True ModoBuscar End Sub Private Sub txtBuscar_Change() If txtBuscar.Text <> "" Then cmdBuscar.Enabled = True Else cmdBuscar.Enabled = False End If End Sub ' activa el modo de búsqueda Public Sub ModoBuscar() If bReemplazar Then lblReemplazar.Visible = False txtReemplazar.Visible = False cmdReemplazar.Visible = False cmdReemplazarTodo.Visible = False Me.Height = 1530 bReemplazar = False End If If txtBuscar.Text <> "" Then txtBuscar.SelStart = 0 txtBuscar.SelLength = Len(txtBuscar.Text) End If End Sub ' activa el modo de reemplazar Public Sub ModoReemplazar() If Not bReemplazar Then lblReemplazar.Visible = True txtReemplazar.Visible = True cmdReemplazar.Visible = True cmdReemplazarTodo.Visible = True Me.Height = 2520 bReemplazar = True End If If txtBuscar.Text <> "" Then txtBuscar.SelStart = 0 txtBuscar.SelLength = Len(txtBuscar.Text) End If End Sub