Tip

Get the reverse of an alias

If you have a field called "KeywordList" that has the following values:

"Test1 | 1"
"Test2 | 2"
"Test3 | 3"
"Test4 | 4"
"Test5 | 5"

That you use to populate another keyword field Called "SelectFromList" 

After a person selects the values: 
Test1
Test5 
the values 1,5 are stored in "SelectFromList."

For whatever reason, you need to know the Alias. If the list is very
large, this becomes very difficult.
The GetReverseAlias function tells you what those Alias are.  

How to call
Call doc.ReplaceItemValue( "SelectedFromListAlias" , GetReverseAlias(
doc.GetItemValue( "KeywordList" ), doc.GetItemValue( "SelectFromList" ))  )


Function GetReverseAlias( varAllList As Variant, varKeywords As Variant ) As Variant
	Dim Alllist List As String
	Dim strAlias As String
	Dim strValue As String
	
	Dim strReturn() As String
	Dim intCount As Integer
	intCount = 0
	Redim strReturn(intCount)
	strReturn(intCount) = ""
	
	Forall strOneValue In varAllList
		strAlias = Trim( LeftOfString( Cstr( strOneValue ), "|" ) )
		strValue = Trim( RightOfString( Cstr( strOneValue ), "|" ) )
		If Not ( Iselement( AllList( strValue ) ) ) Then
			Alllist( strValue )  = strAlias
		End If
	End Forall
	
	Forall strOneKeyword In VarKeywords
		Redim Preserve strReturn(intCount)
		If  Iselement( AllList( strOneKeyword ) ) Then
			strReturn(intCount) = Alllist( strOneKeyword ) 
		Else 	
			strReturn(intCount) = ""
		End If
		intCount = intCount + 1
	End Forall
	
	GetReverseAlias = strReturn
End Function

Function RightOfstring ( strSource As String, strSearch As String ) As String
	Dim intPos As Integer
	Dim intLength As Integer
	Dim intStart As Integer
	
	intPos = Instr ( strSource, strSearch )
	intLength = Len( strSource )
	intStart = intLength - ( intPos + Len( strSearch ) - 1 )
	RightOfstring = Right ( strSource, intStart )
End Function

Function LeftOfstring ( strSource As String, strSearch As String ) As String
	Dim intPos As Integer
	intPos = Instr ( strSource, strSearch )
	If intPos > 0 Then intPos = intPos -1
	LeftOfstring = Left ( strsource, intPos )
End Function

This was first published in June 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.