search number in a text string 
Author Message
 search number in a text string

Hi, Dear all,
How can I search a number in a text string quickly?
I have tried to use Val(Text), but it dones not
successfull.

My destination is to find all number in a text string.
please help me!!!!

Thanks,

Daniel



Tue, 28 Jun 2005 18:16:41 GMT  
 search number in a text string
Hi,
Instr(cstr(yournumberhere)))
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620


Quote:
> Hi, Dear all,
> How can I search a number in a text string quickly?
> I have tried to use Val(Text), but it dones not
> successfull.

> My destination is to find all number in a text string.
> please help me!!!!

> Thanks,

> Daniel



Tue, 28 Jun 2005 19:05:50 GMT  
 search number in a text string
Daniel,
Let me add a little to the response Jan gave. When I read your post it
sounds like you want to find any and all numbers in a text string, not
just a single digit. As an example, assume your text string is:
12FS+3d. The following code will find the location of all three digits
in the string and put the locations into an array for use elsewhere in
your code.

Sub FindNumInString()
Dim DigLocation() As Integer
str1 = "12FS+3d"
Redim DigLocation(Len(str1))
i = 1
p = 1
While p <= Len(str1) And p > 0
    For dig = 0 To 9
        If InStr(1, str1, CStr(dig)) > 0 Then
            p = InStr(1, str1, CStr(dig))
            DigLocation(i) = p
            i = i + 1
            str1 = Mid(str1, p + 1)
            Exit For
        Else
            p = 0
        End If

    Next
Wend
a = DigLocation(1)            'value = 1
b = DigLocation(2)            'value = 2
c = DigLocation(3)            'value = 6

End Sub

Hope this helps,
John



Wed, 29 Jun 2005 11:45:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Search for a text string in text file

2. Searching for a number in a string of varying length

3. Searching *.doc for text strings

4. How can I use VBA to search all modules for a text string

5. Searching Memo Field For Text Strings

6. Search for and Replace strings in a text file

7. Problem importing text file and searching for strings

8. searching for a text string in the footer

9. VBA to select all text bewteen 2 different search strings and delete

10. searching for a string within a text box..

11. Function to search text file for given string

12. Slow Searching Text File / String

 

 
Powered by phpBB® Forum Software