Skip to main content

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy

Hi besafe, 

you do not mention which programming language you are using, here is some sample VBA, to demo how to parse the string and rebuild the street, house number and post code.

Sub MySplitter()
    MyString = "This is my street name 12-a 1234"
  Dim mySubStrings() As String
  ReDim mySubStrings(1)
  i = 1
  Do While i > 0
    i = InStr(i, MyString, " ")
    If i = 0 Then Exit Do
    mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
    ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
    MyString = Right(MyString, Len(MyString) - i)
    i = 1
  Loop
  mySubStrings(UBound(mySubStrings)) = MyString

  For i = 1 To UBound(mySubStrings) - 2
    MyStreet = MyStreet & mySubStrings(i) & " "
  Next i
  MyStreet = Left(MyStreet, Len(MyStreet) - 1)

  MsgBox "Street = " & MyStreet
  MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
  MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))
End Sub

Note: I don't handle any scenario whey there is no post code or no house number

Cheers,
Tom


Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy

Hi besafe, 

you do not mention which programming language you are using, here is some sample VBA, to demo how to parse the string and rebuild the street, house number and post code.

Sub MySplitter()
    MyString = "This is my street name 12-a 1234"
  Dim mySubStrings() As String
  ReDim mySubStrings(1)
  i = 1
  Do While i > 0
    i = InStr(i, MyString, " ")
    If i = 0 Then Exit Do
    mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
    ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
    MyString = Right(MyString, Len(MyString) - i)
    i = 1
  Loop
  mySubStrings(UBound(mySubStrings)) = MyString

  For i = 1 To UBound(mySubStrings) - 2
    MyStreet = MyStreet & mySubStrings(i) & " "
  Next i
  MyStreet = Left(MyStreet, Len(MyStreet) - 1)

  MsgBox "Street = " & MyStreet
  MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
  MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))
End Sub

Note: I don't handle any scenario whey there is no post code or no house number

Cheers,
Tom


Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
thanks for the answer, however i can't really understand the first part, because i want to read the adress somewhere at first and then rebuild it into three categoriez

i thought that you would first say :

Emreadscreen status1,30,7,21 as an example and then rebuild the adress around what the computer reads

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
when i tried to make this, the way i thought it should be with the code you send me:

emreadscreen status1,30,7,21
MyString = status1
Dim mySubStrings() As String
ReDim mySubStrings(1)
i = 1
Do While i > 0
i = InStr(i, MyString, " ")
If i = 0 Then Exit Do
mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
MyString = Right(MyString, Len(MyString) - i)
i = 1
Loop
mySubStrings(UBound(mySubStrings)) = MyString

For i = 1 To UBound(mySubStrings) - 2
MyStreet = MyStreet & mySubStrings(i) & " "
Next i
MyStreet = Left(MyStreet, Len(MyStreet) - 1)

MsgBox "Street = " & MyStreet
MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))

the msgbox for street would show the whole adresse instead of making it into three categoriez

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy

Hi Besafe,

If I harde  code the status1 string "tumleby 12 2345 tasstrup" and I execute the code you provided above

Sub Main

' emreadscreen status1,30,7,21
status1 = "tumleby 12 2345 tasstrup"
MyString = status1
Dim mySubStrings() As String
ReDim mySubStrings(1)
i = 1
Do While i > 0
i = InStr(i, MyString, " ")
If i = 0 Then Exit Do
mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
MyString = Right(MyString, Len(MyString) - i)
i = 1
Loop
mySubStrings(UBound(mySubStrings)) = MyString
For i = 1 To UBound(mySubStrings) - 2
MyStreet = MyStreet & mySubStrings(i) & " "
Next i
MyStreet = Left(MyStreet, Len(MyStreet) - 1)
MsgBox "Street = " & MyStreet
MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))
End Sub

I get the following
    
can you let us know what value of status1 you are reading from the display terminal?

Thanks,
Tom


Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
an little extra thing, i found out the adress would actually be set up as "Bumlevej 40 3000 humble"

so a street name, a housenumber, postcode, and a city name

this only confusses me even more

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
Hi Besafe,

maybe this is clearer..

Sub Main
' emreadscreen status1,30,7,21

status1 = "Bumlevej 40 3000 humble"

MyString = status1
Dim mySubStrings() As String
ReDim mySubStrings(1)
i = 1
Do While i > 0
i = InStr(i, MyString, " ")
If i = 0 Then Exit Do
mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
MyString = Right(MyString, Len(MyString) - i)
i = 1
Loop
mySubStrings(UBound(mySubStrings)) = MyString
For i = 1 To UBound(mySubStrings) - 2
MyStreet = MyStreet & mySubStrings(i) & " "
Next i
MyStreet = Left(MyStreet, Len(MyStreet) - 1)
MsgBox "Street = " & MyStreet
MsgBox "Postcode = " & mySubStrings(UBound(mySubStrings) - 1)
MsgBox "City = " & mySubStrings(UBound(mySubStrings))
End Sub

My bad on the message boxes, the most important part is that the bits to the right of the "=" are what you are looking for.

The above splits the stings based of spaces, and then is set the City to the last string, the post code to the second last string and the house bits to what remains.

This will work fine is the City part is only one word, but say we had

"Bumlevej 40 1234 Vester Egesborg", then we have a problem with the above code, as it will split the address into
"Bumlevej 40 1234" , "Vester" and "Egesborg".

Naturally we can fix that, but again we need to work to a list of ground rules, which only you can provide.

Tom

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
so when i run the code:

Sub Main

emreadscreen status1,30,7,21
MyString = status1
Dim mySubStrings() As String
ReDim mySubStrings(1)
i = 1
Do While i > 0
i = InStr(i, MyString, " ")
If i = 0 Then Exit Do
mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
MyString = Right(MyString, Len(MyString) - i)
i = 1
Loop
mySubStrings(UBound(mySubStrings)) = MyString
For i = 1 To UBound(mySubStrings) - 2
MyStreet = MyStreet & mySubStrings(i) & " "
Next i
MyStreet = Left(MyStreet, Len(MyStreet) - 1)
MsgBox "Street = " & MyStreet
MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))
End Sub

my msgbox will come up with the following:

MyStreet = "tumleby 12 2345 tasstrup"
HouseNumber = " "
PostCode = " "

however if i run it like this:

Sub Main

'emreadscreen status1,30,7,21
status1 = "tumleby 12 2345 tasstrup"
MyString = status1
Dim mySubStrings() As String
ReDim mySubStrings(1)
i = 1
Do While i > 0
i = InStr(i, MyString, " ")
If i = 0 Then Exit Do
mySubStrings(UBound(mySubStrings)) = Left(MyString, (i - 1))
ReDim Preserve mySubStrings(UBound(mySubStrings) 1)
MyString = Right(MyString, Len(MyString) - i)
i = 1
Loop
mySubStrings(UBound(mySubStrings)) = MyString
For i = 1 To UBound(mySubStrings) - 2
MyStreet = MyStreet & mySubStrings(i) & " "
Next i
MyStreet = Left(MyStreet, Len(MyStreet) - 1)
MsgBox "Street = " & MyStreet
MsgBox "HouseNumber = " & mySubStrings(UBound(mySubStrings) - 1)
MsgBox "PostCode = " & mySubStrings(UBound(mySubStrings))
End Sub

it will be splitted up almost perfect
Street = "tumleby 12"
HouseNumber = "2345"
Postcode = "taastrup"

however it would be nice if it would be set up like

street = "tumleby"
Housenumber = "12"
Postcode = "2345"
cityname = "taastrup"

but what i don't understand is when im just reading the adress and syncing it with Mystring, it won't split the adress. however if i write the adress into the status1 and syncing it with MyString it splits it without any errors.

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
also the value of status1 when i make it show it through a msgbox is exactly as i wrote it:

msgbox = tumleby 12 2345 tasstrup

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
i just understood what you meant by value of status1...

so when you are copying status1 into the pc you would get the address(24 letters) and an extra 6 spaces. I think this is were it is failing, since i just tried to copy only the exact address and then the code would work perfectly, but since the addresses which has to be copied is constantly changing, i believe there must be a solution to this. do you know if there is anyway to make it work?

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
Hi besafe,

so the string you need to read from the display terminal at row 7 col 21 varies in length. In this case you should be able to read the max possible length for the string and then you can RTrim$ then string, which will remove all trailing spaces.

Similarly you can use LTrim$(Status1) to remove any leading spaces.

e.g. is your Status1 = " tumleby 12 2345 tasstrup ",
then,
status1 = RTrim$(status1)
will equal
" tumleby 12 2345 tasstrup"
and then an LTrim$(status1) will give you
"tumleby 12 2345 tasstrup"
which you can then parse out into it's bits using an InStr in a Do .... Loop

Tom

Hello Community

 

i am working on a project were i need to copy adresses on one specific line which could state "Bumlevej  40  3000"

 

this information should be categorized in order as such:

"Bumlevej"

"40"

"3000"

 

my problem is that since the adresses are continuesly changing i cannot just make rumba copy specific number of characters... does anyone have an idea to solve this problem? if possible could you also show me somekind of code which could do it. 

 

any help is appreciated :D

 


#Rumba
#novice
#Copy
Hi besafe,

so the string you need to read from the display terminal at row 7 col 21 varies in length. In this case you should be able to read the max possible length for the string and then you can RTrim$ then string, which will remove all trailing spaces.

Similarly you can use LTrim$(Status1) to remove any leading spaces.

e.g. is your Status1 = " tumleby 12 2345 tasstrup ",
then,
status1 = RTrim$(status1)
will equal
" tumleby 12 2345 tasstrup"
and then an LTrim$(status1) will give you
"tumleby 12 2345 tasstrup"
which you can then parse out into it's bits using an InStr in a Do .... Loop

Tom