Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse begining of a string

Status
Not open for further replies.

storm69

Technical User
Jan 31, 2006
26
US
I am very very green at VB Scripts but trying hard to learn. I have an application for a home automation computer that uses VB Scripts. I need to extract just the first portion of the string and it's my understanding that I need to "Parse" the string. Here is the Script:

sub Devices_CIDUpdate(ID)
If ID = "1234567890" Then
Character.Speak "Steve is calling"
else
Server.EntryLog("Caller ID: " & ID)
End If
end sub

The HA computer sends the following string;

1234567890U.S. CELLULAR 01301200
The last 8 numbers are a time stamp sent by the phone carrier.

What I need to do is "Parse" or exclude everything except the 1st 10 numbers (phone number). Any help would be greatly appreciated.
 
[tt]
x=" 1234567890U.S. CELLULAR 01301200"
y=left(x,10) 'what you need for fixed-length (10) format
[/tt]
 
There seems to have a boggus space in front of 1. It is an artifact. Take it out. It is not intended to be there.
[tt] x=[highlight]"1[/highlight]234567890U.S. CELLULAR 01301200"
[/tt]
 
I will try that but I still have another question in regards to the time stamp. Since the date/time stamp will always be different then how would you compensate for that in the string?
 
i thought you were just after the first 10 characters?

with regards to the date/time stamp i guess it all comes down to the application which spits out the values as to how they are formatted?
 
I had to change it a little but got it to work, thanks so much for everyones help. I did the following in order to get it to work the way I needed it.

x=ID
y=left(x,10)
 
y = Left(ID, 10)

is enough, you dont need the x = ID
 
That makes sense, thanks, again I am very green at this, at the very bottom of the power curve but learning.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top