PC Review


Reply
Thread Tools Rate Thread

remove alpha & special characters from field

 
 
=?Utf-8?B?amVubmlmZXI=?=
Guest
Posts: n/a
 
      6th Dec 2005
Hi -

I have an alpha numeric field with entries of varying length and would like
to just keep the numbers

C/O NICK W MANFIELD9653 W BLACKJACK RIDGE

would become 9653

Any help would be appreciated! Thanks
 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      6th Dec 2005
Here is a bit of code I wrote a while back. Copy it and put it into a
module. Then you can call it when you want.


'----------------- Code starts ------------------------
Public Function fStripToNumbersOnly(ByVal varText As Variant) As String
'Takes input and returns only the numbers in the input. Strips out
'all other characters. Handles nulls, dates, numbers, and strings.

Const strNumbers As String = "0123456789"
Dim strOut As String
Dim intCount As Integer

If Len(varText & "") = 0 Then
strOut = ""

Else
varText = varText & ""
For intCount = 1 To Len(varText)
If InStr(1, strNumbers, Mid(varText, intCount, 1)) > 0 Then
strOut = strOut & Mid(varText, intCount, 1)
End If
Next intCount
End If

fStripToNumbersOnly = strOut

End Function
'---------- Code ends ----------------

"jennifer" <(E-Mail Removed)> wrote in message
newsFCA6E15-25FE-4650-A4E2-(E-Mail Removed)...
> Hi -
>
> I have an alpha numeric field with entries of varying length and would
> like
> to just keep the numbers
>
> C/O NICK W MANFIELD9653 W BLACKJACK RIDGE
>
> would become 9653
>
> Any help would be appreciated! Thanks



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VALIDATION USING ALPHA-NUMERICS ONLY - NO SPECIAL CHARACTERS KLZA Microsoft Excel Programming 6 10th Aug 2007 09:34 PM
VALIDATION USING ALPHA-NUMERICS ONLY - NO SPECIAL CHARACTERS KLZA Microsoft Excel Programming 0 10th Aug 2007 08:20 PM
Re: Need to remove all spaces and special characters from a field John Nurick Microsoft Access Getting Started 3 22nd Jan 2007 02:09 PM
Display only the alpha characters in a field w/both alpha&numeric. =?Utf-8?B?QXJibyBN?= Microsoft Access Queries 1 16th Dec 2004 09:19 AM
can textbox accept special characters like "( ,)'-" along alpha =?Utf-8?B?U3RhbiBILg==?= Microsoft Access VBA Modules 6 10th Nov 2004 08:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:55 AM.