RICHTEXTBOX - LOCALIZAR NUMEROS ALEATORIOS

HEV8050 13/11/2012 09:10:02
#414089
Bom dia amigos. preciso saber como localizar uma sequencia de números que está em um arquivo rtf. Porém, só tenho a forma de como ele está escrito, mas não tenho o valor correto.
Ex: preciso procurar o número 2012.001122/3 que é um número de processo. só sei que ele está escrito nessa forma, mas não sei o número correto.
Preciso fazer um busca usando caractere curinga, tipo: nnnn.nnnnnn/n.
Alguém poderia me ajudar?
Agradeço antecipadamente.
MARCELO.TREZE 13/11/2012 10:43:33
#414101
por curinga acho meio complicado mas poderia ser feito o seguinte, você poderia usar o instr e determinar as posições de caracteres especificos.

tipo se encontrar . (ponto) e após 6 caracteres encontrar / (barra) então é o numero do contrato.


VELDRAME 13/11/2012 15:16:12
#414137
Use Expresão Regular
http://support.microsoft.com/kb/818802/pt-br
Function TestRegExp(myPattern As String, myString As String)
[ô]Create objects.
Dim objRegExp As RegExp
Dim objMatch As Match
Dim colMatches As MatchCollection
Dim RetStr As String

[ô] Create a regular expression object.
Set objRegExp = New RegExp

[ô]Set the pattern by using the Pattern property.
objRegExp.Pattern = myPattern

[ô] Set Case Insensitivity.
objRegExp.IgnoreCase = True

[ô]Set global applicability.
objRegExp.Global = True

[ô]Test whether the String can be compared.
If (objRegExp.Test(myString) = True) Then

[ô]Get the matches.
Set colMatches = objRegExp.Execute(myString) [ô] Execute search.

For Each objMatch In colMatches [ô] Iterate Matches collection.
RetStr = RetStr & [Ô]Match found at position [Ô]
RetStr = RetStr & objMatch.FirstIndex & [Ô]. Match Value is [ô][Ô]
RetStr = RetStr & objMatch.Value & [Ô][ô].[Ô] & vbCrLf
Next
Else
RetStr = [Ô]String Matching Failed[Ô]
End If
TestRegExp = RetStr
MsgBox RetStr
End Function

Private Sub Command_Click()
[ô]Chama a Função
Call TestRegExp([Ô][0-9]{4}.[0-9]{5}/[0-9]{1}[Ô], Text.Text)
End Sub
HEV8050 19/11/2012 06:44:36
#414404
Obrigado, amigos, vou tentar.
Tópico encerrado , respostas não são mais permitidas