Hi John
This would work in theory, and would be great for eliminating one or two specific characters, but in this case we wish to keep only a few (ten) out of 256 possible characters (maybe more with Unicode). Even if you wanted to eliminate just letters, you would need at least 26 (possibly 52) Replace statements – one for each letter, and maybe one for each case of each letter.
Warmly,
Graham
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Sunday, 6 May 2018 21:11
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Re: How to remove letters from strings with code?
Hello all,
Out of curiosity, would the Replace method work in this case:
Replace(strYourString, ?, "")
I am on travel at the moment and do not have access to Access, otherwise I would try it...
John
On Sat, May 5, 2018 at 8:37 PM qingqinga qingqinga@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
Dear Graham,
Thanks a lot.
Best Regards,
Kevin
发自 WPS邮箱客戶端
在 "graham@mandeno.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com>,2018年5月6日 08:19写道:
Hi Kevin
A function like this should do the trick:
Public Function KeepOnlyNumeric( strIn as String ) As String
Dim strOut As String
Dim ch as String
Dim i as Integer
For i = 1 to Len(strIn)
ch = Mid(strIn, i, 1)
Select Case ch
Case "0" To "9"
strOut = strOut & ch
End Select
Next i
KeepOnlyNumeric = strOut
End Function
Warmly,
Graham
---In MS_Access_Professionals@yahoogroups.com, <qingqinga@...> wrote :Dear All,
How to remove letters from strings with code, only keep the numbers? For example:
H2562 to 2562
Thanks in advance.Best Regards,
Kevin
Posted by: "Graham Mandeno" <graham@mandeno.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
Tidak ada komentar:
Posting Komentar