|
-
Jun 4th, 2004, 02:29 PM
#1
Thread Starter
Lively Member
Extracting text from a string.
I was finally able to find an API to copy all text from a terminal emulator (legally provided by the software company).
There is a USA Social Security number I would like to extract and disregard all the other text. Once the SSN is narrowed down from all the text, can we assign it to a variable?
I thought a RegEx would do it but probably not. I can't hardcode a social security number (defeats the purpose). Any ideas?
Chris
-
Jun 4th, 2004, 02:35 PM
#2
How about this ???
VB Code:
'if you know SSN position within that text
'then use Mid() function to assign it to some global/local var
Dim strSSN As String
strSSN = Mid(strText, intSatr, int End)
'you are now ready to use it
-
Jun 4th, 2004, 02:37 PM
#3
Does the security number always start from the same position?
-
Jun 4th, 2004, 02:41 PM
#4
Thread Starter
Lively Member
Hmm I wish the positioning of the SSN was the same place everytime. So let's say our string variable that copied all the application's text has alot of characters like this:
strTheAppsString = "123 Application Name: Chris Last Name: Chang Tele: %%^$%%^ SSN: 666-66-6666"
Sometimes it would look like this:
strTheAppsString = "123 Application Name: SSN: 666-66-6666" Chris Last Name: Chang Tele: %%^$%%^
Another idea would be to Extract 11 characters after we parse through and if we see "SSN:" in the string, extract 11 #'s.
Thanks for any ideas 
Chris
-
Jun 4th, 2004, 03:13 PM
#5
VB Code:
Dim Temp As String, Temps() As String
Temps = Split(InputString, "SSN: ")
If UBound(Temps) > 0 Then Temp = Left$(Temps(1), 11)
' Temp should now be either empty or contain the number
-
Jun 4th, 2004, 05:21 PM
#6
Thread Starter
Lively Member
Merri,
Awesome code! Would you happen to know how to remove the hyphens too while we're on this subject?
Chris
-
Jun 4th, 2004, 05:32 PM
#7
Hyphens? The - character? (English isn't my native)
VB Code:
Temp = Replace$(Left$(Temps(1), 11), "-", vbNullString)
'vbNullString is the same as "", but it is recommended to use vbNullString
-
Jun 5th, 2004, 03:10 AM
#8
PowerPoster
VB Code:
Dim TheString As String, TheArray() As String
TheString = "123 Application Name: SSN: 666-66-6666 Chris Last Name: Chang Tele: %%^$%%^"
TheArray = Split(TheString, "SSN: ")
MsgBox Mid(TheArray(1), 1, 11)
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
Jun 7th, 2004, 11:16 AM
#9
Thread Starter
Lively Member
Merri, Arc:
Both samples work! Thank you for helping me out!
Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|