|
|
|
Sample code for using RecogniContact/COM address parser in
Visual Basic .NET
NOTE!
- Make sure to first add RecogniContact.dll to the project
references as decribed here
- Replace [YOUR NAME] and [YOUR LICENSE KEY] with your license
details
Private Sub demoButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles demoButton.Click
Dim parser As RecogniContact.Parser
Dim parserSettings As RecogniContact.IParserSettings
Dim parsedContact As RecogniContact.IParsedContact
parser = New RecogniContact.Parser
'Address parser initialization
'-----------------------------
parser.Initialize("[YOUR NAME]", "[YOUR LICENSE KEY]")
'create the address parser settings object
'-----------------------------------------
parserSettings = parser.CreateSettingsObject()
'modify the address parser settings object
'-----------------------------------------
parserSettings.TranslateExistingCountryNames = True
parserSettings.CountryNameLanguage = RecogniContact.Language.Language_EN
parserSettings.StandardizePhoneNumberFormat = True
parserSettings.InternationalPhoneNumber_IntlAccessCode = "+"
parserSettings.InternationalPhonePrefixFormat = "_(123)_"
parserSettings.MakeAllPhoneNumbersInternational = True
parserSettings.MakeAllPhoneNumbersInternational_DefaultCountry = RecogniContact.Country.Country_US
'activate the new address parser settings
'----------------------------------------
parser.Settings(parserSettings)
'do the address parsing
'----------------------
parsedContact = parser.Parse("Dr. Walter W. Wagoner - Exhibition Manager" + vbCrLf + _
"The Museum of Modern Art" + vbCrLf + _
"Address: 11 West 53 Street, New York, NY 10019" + vbCrLf + _
"Phone: (212) 708-9400" + vbCrLf + _
"Email: info@moma.org" + vbCrLf + _
"Web: www.moma.org")
'now use
' parsedContact.GetValue()
'to access the parsed values
'show the country
MsgBox("Country = " + parsedContact.GetValue(RecogniContact.ContactFieldType.ContactFieldType_Country))
'Call GetValue() with any of the following arguments:
' RecogniContact.ContactFieldType.ContactFieldType_Prefix
' RecogniContact.ContactFieldType.ContactFieldType_FirstName
' RecogniContact.ContactFieldType.ContactFieldType_MiddleName
' RecogniContact.ContactFieldType.ContactFieldType_LastName
' RecogniContact.ContactFieldType.ContactFieldType_Suffix
' RecogniContact.ContactFieldType.ContactFieldType_Company
' RecogniContact.ContactFieldType.ContactFieldType_Company2
' RecogniContact.ContactFieldType.ContactFieldType_Position
' RecogniContact.ContactFieldType.ContactFieldType_StreetAddress1
' RecogniContact.ContactFieldType.ContactFieldType_StreetAddress2
' RecogniContact.ContactFieldType.ContactFieldType_PostboxAddress
' RecogniContact.ContactFieldType.ContactFieldType_PostboxPostCode
' RecogniContact.ContactFieldType.ContactFieldType_PostCode
' RecogniContact.ContactFieldType.ContactFieldType_PlaceName
' RecogniContact.ContactFieldType.ContactFieldType_Province
' RecogniContact.ContactFieldType.ContactFieldType_Country
' RecogniContact.ContactFieldType.ContactFieldType_Phone1
' RecogniContact.ContactFieldType.ContactFieldType_Phone2
' RecogniContact.ContactFieldType.ContactFieldType_Mobile
' RecogniContact.ContactFieldType.ContactFieldType_Fax
' RecogniContact.ContactFieldType.ContactFieldType_Email
' RecogniContact.ContactFieldType.ContactFieldType_Url
' RecogniContact.ContactFieldType.ContactFieldType_Gender
' RecogniContact.ContactFieldType.ContactFieldType_CountryIsoCode
End Sub
|