Solved Separate numbers from text (1 Viewer)

Matin_Murad

Member
Local time
Yesterday, 18:23
Joined
Jul 1, 2020
Messages
37
I want to extract numbers only from the text box containing numbers and letters
 

Attachments

  • abc.accdb
    468 KB · Views: 61

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:23
Joined
Oct 29, 2018
Messages
21,477
It might also help to provide the end result you're expecting to get out of the sample data you provided. For example, what would be the correct result if the data is "12counting60000save50000?"
 

Matin_Murad

Member
Local time
Yesterday, 18:23
Joined
Jul 1, 2020
Messages
37
النتيجة النهائية لـ 12 عد 60000 حفظ 50000
126000050000
 

Attachments

  • vvc.png
    vvc.png
    4.4 KB · Views: 40

Matin_Murad

Member
Local time
Yesterday, 18:23
Joined
Jul 1, 2020
Messages
37
'بفضل الجميع ، تم العثور على حل

Public Function ExcludeText(InputValue As String) As String
Dim varCharCnt
Dim cntr
Dim strChar As String
varCharCnt = Len(InputValue)
For cntr = 1 To varCharCnt
strChar = Mid(InputValue, cntr, 1)
If Asc(strChar) <= 65 And Asc(strChar) <> 32 _
And Asc(strChar) <> 46 And Asc(strChar) <> 44 Then
ExcludeText = ExcludeText & strChar
End If
Next cntr
End Function


[/الشفرة]
 

Gasman

Enthusiastic Amateur
Local time
Today, 02:23
Joined
Sep 21, 2011
Messages
14,317
That logic might work if it was English, but you appear to want to to read from right to left, but display left to right?
Are there spaces either side of the numbers? Hard to tell unless within code tags :(
 

Moosak

New member
Local time
Today, 02:23
Joined
Jan 26, 2022
Messages
26
Try this one to extract Numbers from the text
Code:
Public Function ExtractNumbersFromText(strText As String)
Dim x As Long
Dim L As String
Dim r As String

For x = 1 To Len(strText)

    L = Mid(strText, x, 1)
    If IsNumeric(L) Then
    r = r & L
    End If
Next x
ExtractNumbersFromText = r
End Function

and to extract the text and remove the numbers use this one:
Code:
Public Function RemoveNumbersFromText(strText As String)
Dim x As Long
Dim L As String
Dim r As String

For x = 1 To Len(strText)

    L = Mid(strText, x, 1)
    If Not IsNumeric(L) Then
    r = r & L
    End If
Next x
RemoveNumbersFromText = r
End Function

1657956819199.png
 

Attachments

  • abc.accdb
    468 KB · Views: 65
Last edited:

Users who are viewing this thread

Top Bottom