removing part of a field

  • Thread starter Thread starter Ole
  • Start date Start date
O

Ole

Guest
When importing a text in access2000, fields contain both text and numbers (datatype text). What i want is to remove the text, in the field, and just have the numbers left (Numbers can still be datatype text). This have to be automated with code since it is a large numbers of files.
The text is the same for all the files, so it could maybe be done with just typing the text, to be removed, in the code?

This sounds like a simple task but i could not find anything about it in my books.

Thanks for helping.
 
If the format is the same eg. 123abc 123abc
Then you can parse the letters or numbers from the string
 
use:
Function num(str As String) As Variant
Dim i As Integer
i = 1
Do
If Asc(Mid(str, i, 1)) >= 48 And Asc(Mid(str, i, 1)) <= 57 Then
num = num + Mid(str, i, 1)
If Not (Asc(Mid(str, i + 1, 1)) >= 48 And _
Asc(Mid(str, i + 1, 1)) <= 57) Then Exit Function
End If
i = i + 1
Loop
End Function

you recieve:
"12345ddd"->12345
"ddd12345ddd"->12345
"ddd12345"->12345
"12dd34dd5"->12
 

Users who are viewing this thread

Back
Top Bottom