473,748 Members | 8,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

split adress and number?

Hi, a very newbie question. How do I split the adress and number to 2
variables?
ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347"

Ill guess i have to search the string from left to right after first
apperence of a number, but how do i do that?

Regards

Martin
Jul 19 '05 #1
9 1775
"martin" wrote:
: Hi, a very newbie question. How do I split the adress and number to 2
: variables?
: ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347"
:
: Ill guess i have to search the string from left to right after first
: apperence of a number, but how do i do that?

dim myString, myArray
myString = "Kingsroad 347"
myArray = Split(myString, " ")
Response.Write( myArray(0)) '---- Kingsroad
Response.Write( myArray(1)) '---- 347

or

dim myString, myArray, i
myString = "Kingsroad 347"
myArray = Split(myString, " ")
for i = lbound(myArray) to ubound(myArray)
Response.Write( myArray(i) & "<br />" & vbCrLf)
next

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #2

"Roland Hall" <nobody@nowhere > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"martin" wrote:
: Hi, a very newbie question. How do I split the adress and number to 2
: variables?
: ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347"
:
: Ill guess i have to search the string from left to right after first
: apperence of a number, but how do i do that?

dim myString, myArray
myString = "Kingsroad 347"
myArray = Split(myString, " ")
Response.Write( myArray(0)) '---- Kingsroad
Response.Write( myArray(1)) '---- 347

or

dim myString, myArray, i
myString = "Kingsroad 347"
myArray = Split(myString, " ")
for i = lbound(myArray) to ubound(myArray)
Response.Write( myArray(i) & "<br />" & vbCrLf)
next


Thanks alot, but both of your solutions split the string at the first
space(" ").
Is it possible to split at the first apperence of a number.. cos with this
solution it would be a problem if the user had typed in "Kin gsroad 347". Or
am i wrong?
regards

Martin
Jul 19 '05 #3
martin wrote:
"Roland Hall" <nobody@nowhere > wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"martin" wrote:
Hi, a very newbie question. How do I split the adress and number to
2 variables?
ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 =
"347"

Ill guess i have to search the string from left to right after first
apperence of a number, but how do i do that?


dim myString, myArray
myString = "Kingsroad 347"
myArray = Split(myString, " ")
Response.Write( myArray(0)) '---- Kingsroad
Response.Write( myArray(1)) '---- 347

or

dim myString, myArray, i
myString = "Kingsroad 347"
myArray = Split(myString, " ")
for i = lbound(myArray) to ubound(myArray)
Response.Write( myArray(i) & "<br />" & vbCrLf)
next


Thanks alot, but both of your solutions split the string at the first
space(" ").
Is it possible to split at the first apperence of a number.. cos
with this solution it would be a problem if the user had typed in
"Kin gsroad 347". Or am i wrong?

What if the street name contains a number?

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
>"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
What if the street name contains a number?


Well, in Sweden they dont. But good question.
Is it possible to split a string at first apperence of a number?

/martin
Jul 19 '05 #5
"martin" wrote in message
news:c2******** *****@ID-69224.news.uni-berlin.de...
: >"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
:
: > What if the street name contains a number?
:
: Well, in Sweden they dont. But good question.
: Is it possible to split a string at first apperence of a number?
:
: /martin

Yes, you can do it however you want but you need to have a little
consistency.
Is there a limit on the number of digits?
Do you not want to allow any spaces except between name and number?
What if you had this? Kings Road 3 4 7
Or this? 347 Kingsroad, 347 kings road, 347 KiNGS-RoaD

You could correct this with regular expressions and with using the replace
function but I wouldn't it be easier to require the user to know how to type
in their correct address? In other words, if you are expecting only 1
space, I'd first check to see if there is more than one and if so, return it
back to the user and tell them try again.
Perhaps if you can tell us the known requirements, it would help to devise
something usable.
We need to know what you expect, what you will accept, what the boundaries
are and the order you'd like to have them.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #6

"Roland Hall" <nobody@nowhere > wrote in message
news:et******** ******@tk2msftn gp13.phx.gbl...
"martin" wrote in message
news:c2******** *****@ID-69224.news.uni-berlin.de...
: >"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message
:
: > What if the street name contains a number?
:
: Well, in Sweden they dont. But good question.
: Is it possible to split a string at first apperence of a number?
:
: /martin

Yes, you can do it however you want but you need to have a little
consistency.
Is there a limit on the number of digits?
Do you not want to allow any spaces except between name and number?
What if you had this? Kings Road 3 4 7
Or this? 347 Kingsroad, 347 kings road, 347 KiNGS-RoaD

You could correct this with regular expressions and with using the replace
function but I wouldn't it be easier to require the user to know how to type in their correct address? In other words, if you are expecting only 1
space, I'd first check to see if there is more than one and if so, return it back to the user and tell them try again.
Perhaps if you can tell us the known requirements, it would help to devise
something usable.
We need to know what you expect, what you will accept, what the boundaries
are and the order you'd like to have them.
If this is data you are requesting then ask for it in seperate form fields
otherwise there are tons of data cleansing methods.

Example:

House Number: 347
Street: Kingsroad
Suite/Apt/Unit: 123

Don Verhagen
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #7
Hi,
In the time of keep away the datas in your database you can put some
especial signs in the end of your address like:
==|== (2 equals signs, one pipe sign and 2 equals signs), for example,
I believe that there is not this kind of signs in any street address of any
part of the world.
So you can always split the address using these special signs:
dim myString, myArray
myString = "Kingsroad 347"
myArray = Split(myString, "==|==")
Response.Write( myArray(0)) '---- Kingsroad
Response.Write( myArray(1)) '---- 347

Hope this help.
--

Sem mais,

««««««««»»»»»»» »»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC

"Roland Hall" <nobody@nowhere > escreveu na mensagem
news:#G******** ******@tk2msftn gp13.phx.gbl...
"martin" wrote:
: Hi, a very newbie question. How do I split the adress and number to 2
: variables?
: ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347"
:
: Ill guess i have to search the string from left to right after first
: apperence of a number, but how do i do that?

dim myString, myArray
myString = "Kingsroad 347"
myArray = Split(myString, " ")
Response.Write( myArray(0)) '---- Kingsroad
Response.Write( myArray(1)) '---- 347

or

dim myString, myArray, i
myString = "Kingsroad 347"
myArray = Split(myString, " ")
for i = lbound(myArray) to ubound(myArray)
Response.Write( myArray(i) & "<br />" & vbCrLf)
next

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #8
"Don Verhagen" wrote:
: If this is data you are requesting then ask for it in seperate form fields
: otherwise there are tons of data cleansing methods.
:
: Example:
:
: House Number: 347
: Street: Kingsroad
: Suite/Apt/Unit: 123

Good idea Don. That would cut down on the confusion and testing.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #9
martin wrote:
"Bob Barrows" <re******@NOyah oo.SPAMcom> wrote in message

What if the street name contains a number?


Well, in Sweden they dont. But good question.
Is it possible to split a string at first apperence of a number?

/martin


Well, I wanted to play, so here's a non-regex method:

dim sAddress, sNumber, sName, iPos

If Instr('01234567 89', left(sAddress,1 ))>0 then
'number appears first in address
iPos = InStr(sAddress, " ")
sNumber=left(sA ddress,iPos-1)
sName=mid(sAddr ess,iPos + 1)
else
'assume number appears last, preceded with a space, and
' with no following characters
iPos = InStr(sAddress, " ")
sNumber=mid(sAd dress,iPos+1)
sName=left(sAdd ress,iPos - 1)
end if

You can use this as a model for testing for other conditions.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #10

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

Similar topics

6
2261
by: RosalieM | last post by:
How can i know the nic adress from an incoming socket ? I can easily know the ip adress and port number but how do i have some information about arp level ? Thanks
3
4421
by: rxl124 | last post by:
Hi, room Beginner of learning perl here!! I have question to all, I have below file name datebook.master which contains only 2 lines Mike wolf:12/3/44:144 park ave, paramus: 44000 Sarah kim: 3/2/67:255 lomel ave, fort lee: 33000 Now, I am testing out below scripts and working fine.
20
2726
by: Tom van Stiphout | last post by:
I'm about to write a function like below, which I'm going to call a lot of times. So I care about possible memory leaks. I think whether I should use Erase or not depends on whether Split creates a dynamic array (similar to ReDim a(2)). I have a gut feeling it does. Opinions? Dim a() as String a = Split("part1|part2|part3", "|") ' code that uses a goes here Erase a
0
1438
by: Jarod_24 | last post by:
I got a function that return the url of a image, the problem is that the image control on the .aspx page automaticaly adds the adress of itself to the adress Example: The page http://localhost/myapp/pages/misc/index.aspx calls the function, and it returns the string "images\thumb\001.jpg" The image control on the page will then point to the adress: http://localhost/myapp/pages/misc/images\thumb\001.jpg (wich is wrong).
3
9670
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3... field1...field2...field3...
16
3439
by: Claudio Grondi | last post by:
What started as a simple test if it is better to load uncompressed data directly from the harddisk or load compressed data and uncompress it (Windows XP SP 2, Pentium4 3.0 GHz system with 3 GByte RAM) seems to show that none of the in Python available compression libraries really works for large sized (i.e. 500 MByte) strings. Test the provided code and see yourself.
11
3462
by: mwebel | last post by:
Hi, i had this problem before (posted here and solved it then) now i have the same problem but more complicated and general... basically i want to store the adress of a istream in a char* among other pieces of information information and retrieve it later... like this: *********************** //supossing i have a istream
3
3653
Sagittarius
by: Sagittarius | last post by:
Hi there. I have a problem concerning an UDP socket in C++ (Winsock). The next paragraphs is merely to explain the system I am working on. If U want to skip it, I have marked the question in bold below it. I have a pc, connected to a network of boards, all connected in a ring, all having their own unique IP adresses. As it is now, I send messages to the network of boards via broadcast, so all the boards gets the message. All the...
10
16473
by: kkshansid | last post by:
i have to split adress like raj,2d-raja road,delhi-10008. to raj, raja road, delhi-10008. i can do it with split function but its giving error msg Dim x(3) As String x = Split ({std.addr}, ",") formula = x(2) If Isnull({std.a}) or ({std.b})= "" then
0
8989
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
9367
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
9243
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
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
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
4599
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...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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.