BASIC | How to keep only numeric characters from string?

Is there a short function to replace this one ?

Sub GetOnly0To9
    MsgBox "LibreOffice 6.2.8.2-2" & " = " & SelectOnly0To9("LibreOffice 6.2.8.2-2")
End Sub

Function SelectOnly0To9$(sString$)
	Dim i%, j%
	For i = 1 To Len(sString)
		For j = 0 To 9
			If Mid(sString, i, 1) = cstr(j) Then SelectOnly0To9 = SelectOnly0To9 & j
		Next
	Next
End Function

=REGEX(A1;"[^[:digit:]]";"";"g") assuming cell A1 contains your string.

…or if you really want to use BASIC

Function ExtractDigits$(sString$)
   ExtractDigits=CreateUNOService("com.sun.star.sheet.FunctionAccess").callFunction("REGEX",Array(sString,"[^\d]","","g"))
End Function

Dear @anon73440385

Dear @JohnSUN

Thank you so much.

If neither calculation inside a cell nor the need of a FunctionAccess service are accepted, you can atl least avoid the inner loop using the following code (e.g.):

Function decimalDigitsOnly(pString As String) As String
REM Chr and Asc aren't updated for characters with unicode 
REM numbers >65535 (>&hFFFF).
Dim r As String, u As Long, j As Long, ch As String, co As Integer
r=""
u = Len(pString)
For j = 1 To u
  ch = Mid(pString, j, 1) : co = Asc(ch)
  If (co>47)AND(co<58) Then r = r & ch
Next j
decimalDigitsOnly = r
End Function

It’s not shorter, but hopefully more efficient.
An alternative:

Function decimalDigitsOnly(pString As String) As String
Dim r As String, u As Long, j As Long, ch As String
Const digits = "0123456789"
r=""
u = Len(pString)
For j = 1 To u
  ch = Mid(pString, j, 1)
  If InStr(digits, ch)>0 Then r = r & ch
Next j
decimalDigitsOnly = r
End Function

Dear @Lupp

Thank you so much.