Solved Separate numbers from text

Matin_Murad

Member
Local time
Today, 02:36
Joined
Jul 1, 2020
Messages
39
I want to extract numbers only from the text box containing numbers and letters
 

Attachments

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?"
 
النتيجة النهائية لـ 12 عد 60000 حفظ 50000
126000050000
 

Attachments

  • vvc.png
    vvc.png
    4.4 KB · Views: 96
'بفضل الجميع ، تم العثور على حل

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


[/الشفرة]
 
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 :(
 
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

Last edited:

Users who are viewing this thread

Back
Top Bottom