VB code to Split adresline in adres and number

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hi,

Does anyone know the code (*or point me in the right direction) te split an
adresfield (ie: Streetname 232-B) in 2 separate fields so the result would
be:

Adres = Streetname
Housenumber = 232-B

Txs in advance
Michael

PS: Cause i life in the Netherlands the housenumber comes after the
streetname! and could have any number of possibilities like:

Graaf Florisstraat 2 huis (where [2 huis] indicates the housenumber)
You could say that everything from a nummeric value on is the housenumber
 
I used something similar the other day.

I used :

add_line = "123 street"
len_add = len(add_line)

c=1

do until asc(mid(add_line,c,1))=32
c=c+1
loop

first_part = mid(add_line,1,(c-1))
second_part = mid(add_line,(c+1),(len_add-(c-1))

something like that, have a play, any probs get back and i
will find my code out for you that i used.

Nath
 
Michael said:
Does anyone know the code (*or point me in the right direction) te split an
adresfield (ie: Streetname 232-B) in 2 separate fields so the result would
be:

Adres = Streetname
Housenumber = 232-B

Txs in advance
Michael

PS: Cause i life in the Netherlands the housenumber comes after the
streetname! and could have any number of possibilities like:

Graaf Florisstraat 2 huis (where [2 huis] indicates the housenumber)
You could say that everything from a nummeric value on is the housenumber


You'll have to loop through the string looking for a digit:

Adres = adresfield
Housenumber = ""
For K = 1 To Len(adresfield)
If Mid(adresfield, K, 1) Like "[0-9]" Then
Adres = Left(adresfield, K-1)
Housenumber = Mid(adresfield, K)
Exit For
End If
Next K
 
Txs a lot Guys,

Works like a charm!

Michael

Marshall Barton said:
Michael said:
Does anyone know the code (*or point me in the right direction) te split an
adresfield (ie: Streetname 232-B) in 2 separate fields so the result would
be:

Adres = Streetname
Housenumber = 232-B

Txs in advance
Michael

PS: Cause i life in the Netherlands the housenumber comes after the
streetname! and could have any number of possibilities like:

Graaf Florisstraat 2 huis (where [2 huis] indicates the housenumber)
You could say that everything from a nummeric value on is the housenumber


You'll have to loop through the string looking for a digit:

Adres = adresfield
Housenumber = ""
For K = 1 To Len(adresfield)
If Mid(adresfield, K, 1) Like "[0-9]" Then
Adres = Left(adresfield, K-1)
Housenumber = Mid(adresfield, K)
Exit For
End If
Next K
 
Back
Top