473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is second token odd

Suppose I have a string "12-34 56th Loway" and I want to know if 4 is odd.

Is there someway to do it with STR$ and MID$ &al

Sep 21 '08 #1
6 1820
Assuming the 4 is always in the 5th position, you can use:
If Left([MyString],5) Mod 2 <0 Then
MsgBox "The Fifth Character Of MyString Is Odd"
End If

Steve

<vj*****@at.BioStrategist.dot.dot.comwrote in message
news:gb**********@reader1.panix.com...
Suppose I have a string "12-34 56th Loway" and I want to know if 4 is odd.

Is there someway to do it with STR$ and MID$ &al

Sep 21 '08 #2
On Sun, 21 Sep 2008 19:13:50 +0000 (UTC),
vj*****@at.BioStrategist.dot.dot.com wrote:

If you want to know if 4 is odd:
debug.print (4 mod 2 = 1)

You probably didn't mean to ask that question. What did you want to
ask? What would you consider a token in your example?

-Tom.
Microsoft Access MVP

>Suppose I have a string "12-34 56th Loway" and I want to know if 4 is odd.

Is there someway to do it with STR$ and MID$ &al
Sep 21 '08 #3
Stevie; you really do not know anything about programming.

Your Left command will create a string that includes a dash and you should
get a type error when you try to use that string in a numeric expression.

txt = Mid(originalstring, 5, 1)

' There should be a test her to make sure that txt is a numeric

If txt Mod 2 <0 Then
Debug.Print "The Fifth Character Of MyString Is Odd"
End If

John... Visio MVP

"Steve" <no******@nomsense.comwrote in message
news:Tq******************************@earthlink.co m...
Assuming the 4 is always in the 5th position, you can use:
If Left([MyString],5) Mod 2 <0 Then
MsgBox "The Fifth Character Of MyString Is Odd"
End If

Steve

<vj*****@at.BioStrategist.dot.dot.comwrote in message
news:gb**********@reader1.panix.com...
>Suppose I have a string "12-34 56th Loway" and I want to know if 4 is
odd.

Is there someway to do it with STR$ and MID$ &al


Sep 22 '08 #4
*+-If Left([MyString],5) Mod 2 <0 Then

Well, no, that's why I wanted to parse the second token
(ie, the first token end with a hyphen, the second with a space)

More generally, what are the functions Left, Mid & al "called"?
I remember them from GWBasic, and I know they are MicroSoft specific
but not SQL specific.

- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]
Sep 22 '08 #5
<vj*****@at.BioStrategist.dot.dot.comwrote in message
news:gb**********@reader1.panix.com...
*+-If Left([MyString],5) Mod 2 <0 Then

Well, no, that's why I wanted to parse the second token
(ie, the first token end with a hyphen, the second with a space)

More generally, what are the functions Left, Mid & al "called"?
I remember them from GWBasic, and I know they are MicroSoft specific
but not SQL specific.

- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for
Bimbos]

Are you trying to work out which houses are on the left and which on the
right side of the street?

Left(str,3) will give you the three characters on the left of the string
Right(str,3) will give you the three characters on the right of the string
Mid(str,4,2) will give you two characters starting at position 4
Mid(str,4) will give you all the characters starting at position 4 to the
end of the string
INSTR(str," ") will give you the position of a string in another string

So to answer your original question you may want something like:
Txt = "12-34 fred"
i = InStr(Txt, " ")
Tmpstr = Mid(Txt, i - 1, 1)
if Tmpstr Mod 2 then

Though you could combine the formulas into one, it is safer to keep them
seperate so you could do some error checking.
What if there is no space in the string?
What if the first character is a string?
What if Tmpstr is not numeric?

John... Visio MVP

Sep 22 '08 #6
vj*****@at.BioStrategist.dot.dot.com wrote:
>Suppose I have a string "12-34 56th Loway" and I want to know if 4 is odd.

Is there someway to do it with STR$ and MID$ &al
The problem is about about "314-1376 51st Avenue" which is a made up address in
Alberta. Then there is "1436 51st Avenue" Then there is "313 134 Grove Ave"
Then there is "313B Grove Ave" for the bsmt suite. Then "1446 51B Street" And so
forth.

There are a lot of permutations on this. And no matter how complex there will always
be typos.

Best thing to do is to work on the number of spaces and separate out the components
and then have a person review these especially the oddballs.

Also there is a surprisingly good idea of how complex it can get at the Canada Post
website. http://canadapost.ca/Personal/Tools/Pcl/Advanced.aspx Likely your
governments post office website has similar information.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Sep 23 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andrew James | last post by:
Gentlemen, I'm running into a problem whilst testing the parsing of a language I've created with TPG . It seems that for some reason, TPG balks when I try to parse an expression whose first...
14
by: Simon Morgan | last post by:
I'm trying to write a function to parse a Reverse Polish Notation string from stdin and return 1 token at a time. For those of you who are unaware an RPN string looks like this: 1 2 + 4 * 3 + ...
10
by: Ian Lazarus | last post by:
Hello. How do "unresolved token" link errors occur. How do I fix them? Linking... LINK : error LNK2020: unresolved token (0A000015) ??_7type_info@@6B@ LINK : error LNK2020: unresolved token...
0
by: Jay C. | last post by:
Jay 3 Jan. 11:38 Optionen anzeigen Newsgroups: microsoft.public.dotnet.framework.webservices.enhancements Von: "Jay" <p.brunm...@nusurf.at> - Nachrichten dieses Autors suchen Datum: 3 Jan...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
12
by: Joriveek | last post by:
Hi, I have a little piece of program here Basically what it does is, it copies the strings of variable widths. The basis is until it finds a comma ",". The input is a CSV/Comma Separated...
0
by: Sid DeLuca | last post by:
I'm modifying the WSE2 HOL sample to develop my web service. I'm able to get the client application's username token encrypted on the way out (outputTrace.webinfo), but not on receipt from the...
10
by: Oleg Konovalov | last post by:
Hi, I have a Java GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and clicks...
2
by: Lan Mind | last post by:
Hello again everybody, My page: http://www.dockhawk.com/ I'm trying to implement some "session security" PHP script mentioned in the "Cross-site request forgery" section of this tutorials...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.