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 9 1755
"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
"Roland Hall" <nobody@nowhere> wrote in message
news:%2****************@tk2msftngp13.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
martin wrote: "Roland Hall" <nobody@nowhere> wrote in message news:%2****************@tk2msftngp13.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"
>"Bob Barrows" <re******@NOyahoo.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
"martin" wrote in message
news:c2*************@ID-69224.news.uni-berlin.de...
: >"Bob Barrows" <re******@NOyahoo.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
"Roland Hall" <nobody@nowhere> wrote in message
news:et**************@tk2msftngp13.phx.gbl... "martin" wrote in message news:c2*************@ID-69224.news.uni-berlin.de... : >"Bob Barrows" <re******@NOyahoo.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
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**************@tk2msftngp13.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
martin wrote: "Bob Barrows" <re******@NOyahoo.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('0123456789', left(sAddress,1))>0 then
'number appears first in address
iPos = InStr(sAddress, " ")
sNumber=left(sAddress,iPos-1)
sName=mid(sAddress,iPos + 1)
else
'assume number appears last, preceded with a space, and
' with no following characters
iPos = InStr(sAddress, " ")
sNumber=mid(sAddress,iPos+1)
sName=left(sAddress,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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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
|
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:...
|
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...
|
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...
|
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......
|
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...
|
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...
|
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...
|
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},...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
| |