473,671 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need an expression that will "filter" out 3 alpha-numeric characters in a string

3 New Member
Hello,

I have a table that has a string field "ANUM" that has values that always begin with 089. Then the 3 characters; 089, are followed by between 3 or 4 characters. So a typical value in this field might be 089213 or 0895146. There will never be more than 4 characters, which follows that the total number of characters will not exceed 7.

What I need is an expression that will "filter" out the 089 values, leaving the remainder behind. So the aforementioned values of 089213 and 0895146 would result, after the expression is run, in 213 and 5146, respectively.

Thanks in advance for your replies!

Phil
Mar 20 '07 #1
4 1810
fauxanadu
60 New Member
I would use

Expand|Select|Wrap|Line Numbers
  1. Right(Str(intVariable), len(Str(intVariable)) - 3)
  2.  
If you specifically need the value returned as an integer instead of a string, you can use

Expand|Select|Wrap|Line Numbers
  1. Val(Right(Str(intVariable), len(Str(intVariable)) - 3))
  2.  
Mar 20 '07 #2
fauxanadu
60 New Member
Verbose Explination:
str(strVariable ) returns the number stored in intVariable as a string (so if intVariable = 0891234, str(intVariable = "0891234")
That value is then passed to the len() function which returns the strings length (len("0891234") = 7)
Then 3 is subtracted from it (7 - 3 = 4)
So what we now have is this:
Val(Right("0891 234", 4))
which returns the first 4 characters in "0891234" counting from the right [starting form the 4 in other words] (this returns "1234")
Finally, val() turns "1234" back into a number 1234.
Condensed Explination:
intVariable = 0891234
Val(Right(Str(i ntVariable), len(Str(intVari able)) - 3))
Val(Right(Str(0 891234), len(Str(0891234 )) - 3))
Val(Right("0891 234", len("0891234") - 3))
Val(Right("0891 234", 7 - 3))
Val(Right("0891 234", 4))
Val("1234")
1234
Mar 20 '07 #3
CrazyCruzan
3 New Member
Thanks, your first option worked fine.

Cheers,

Phil
I would use

Expand|Select|Wrap|Line Numbers
  1. Right(Str(intVariable), len(Str(intVariable)) - 3)
  2.  
If you specifically need the value returned as an integer instead of a string, you can use

Expand|Select|Wrap|Line Numbers
  1. Val(Right(Str(intVariable), len(Str(intVariable)) - 3))
  2.  
Mar 20 '07 #4
CrazyCruzan
3 New Member
And Thanks for the both the Verbose AND the Condensed explanations!
Verbose Explination:
str(strVariable ) returns the number stored in intVariable as a string (so if intVariable = 0891234, str(intVariable = "0891234")
That value is then passed to the len() function which returns the strings length (len("0891234") = 7)
Then 3 is subtracted from it (7 - 3 = 4)
So what we now have is this:
Val(Right("0891 234", 4))
which returns the first 4 characters in "0891234" counting from the right [starting form the 4 in other words] (this returns "1234")
Finally, val() turns "1234" back into a number 1234.
Condensed Explination:
intVariable = 0891234
Val(Right(Str(i ntVariable), len(Str(intVari able)) - 3))
Val(Right(Str(0 891234), len(Str(0891234 )) - 3))
Val(Right("0891 234", len("0891234") - 3))
Val(Right("0891 234", 7 - 3))
Val(Right("0891 234", 4))
Val("1234")
1234
Mar 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
10217
by: Marek Mänd | last post by:
This posting will express my concern about the future of css3 forthcoming recommendation. I think for long time now, that the current implementation of CSS attribute opacity is less than usable in practical real life situations. The soon forthcoming CSS3 recommendation does not serve the public interests in this area not at all. The problem relies in the definition what opacity is, how it is to applied to page elements. In past 5...
3
10222
by: Pablito | last post by:
Hi at all please can you inform me how I can use style="FILTER:alpha(opacity=0 to obtein dinamics image effects like fade ? Infact I tryed to use it from javascripts but I am unable from javascript to change the opacity value dinamically regards Pablitoscrpts
4
1904
by: Jeeran | last post by:
We use an ISAPI filter to convert long urls into short clean ones. For example: "Site.com/user/john/" Is re-written as: "Site.com/user/userinfo.aspx?uid=john" Now, "userinfo.aspx" contains a web user control which uses some Atlas functionality; The web user control contains a "DataList" which gets updated asynchronously through Atlas when the user clicks a button –the button is the Atlas trigger.
0
1977
by: gpl666666 | last post by:
I use access to make a "page", below the page form, there are "filter by selection" and "filter toggle button" what are these two bottons for?
0
3491
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table to white the used CSS to set the opacity to 90 so that you can see the background image through the table. The problem I am having is with the textboxes in the transparent
2
2888
by: ManningFan | last post by:
Go into a table where you have a field that has NULL values. Right- Click on a record with a value in that field and choose "Filter Excluding Selection". Some (or most, or all) of your records where there is a NULL value in that field get eliminated. Without getting crazy (i.e. designing your own bottons and "re- inventing the wheel"), is there a way to make Access stop doing this?
1
6042
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly appreciated. Cheers. In the Click() Event of 3 Command Buttons, place the following code: Code: (...
2
6432
nev
by: nev | last post by:
Does anyone know how to do that? In my real project actually, I filter on two fields like this... bindingsource.filter = "col1='" & var1 & "' AND col2='" & var2 & "'" wherein var1 or var2 may contain a null value. Its just the same as if I want to show all records with null values. Any ideas?
1
2260
gcoaster
by: gcoaster | last post by:
Hello, Access is accessing my patience! how does one filter just one form with a single combo box selection? I have a combo box named "cboCallStatus" unbound Row source type = Value List values; OPEN, CLOSED
10
11459
by: vanlanjl | last post by:
I have created a form that contain two combo boxes and two cmd buttons. The idea of the form is that the user will select a search parameter from each combo box then will click the first cmd button "cmdCreateReport". Upon doing so it open a report based of the search criteria. My problems seems to lay with the seconf cmd button : cmdRemoveFilter Private Sub cmdRemoveFilter_Click() On Error Resume Next ' Switch the filter off ...
0
8473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8911
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.