Tip

Workaround for when Notes does not allow commas in lists

Sometimes Notes' imperfections go beyond the annoying and become real problems. For example, you can't show values with embedded commas in a ListBox for a user to select from. When you want to present a list of customer names, this is a real roadblock, as company names with the formats "ABC, INC." and "SMITH, SMITH, & JONES" are very common. As I tried to come up with a workaround, I found the following helpful hint on Notes.Net

Armed with this information, here's how I implemented a solution to this issue:


Sub CommaSubstitute(array As Variant, 
action As String, changed As Integer)

%REM
Purpose:
=======
When values with embedded commas 
appear in a listbox for selection, the 
comma acts as a value  separator, 
although this is not desired. There is 
no way to disable this. So this routine
 is needed to "tweak" existing commas 
so they don't act this way.

Process:
=======
We replace all commas with 
high-order-bit (HOB) commas, which 
look identical to the user,  but Notes does 
not recognize them as a value separator. 
We can also do the reverse,  replacing any
 HOB commas with its original ones.

This sub replaces ALL commas, even 
multiple ones in the same piece of text.

Important! Any time an array is "tweaked" 
so the user can select from it, it should 
be  "untweaked" afterwards! For example, 
if you forget to do this, and you try to use the 
selected value as a key to retrieve a document, 
the document will never be found.  You can use 
the returned value of "changed" to see if this 
step is necessary: if True,  the array was changed, 
so you will have to "untweak" it; if False, you can 
skip this step.

Arguments:
=========

ARRAY = the input array, which will be reviewed 
and changed by this sub.
ACTION = "TWEAK" or "UNTWEAK" = should we 
replace the commas with HOB commas, or  
back out any such existing replacements?
CHANGED = a True/False flag. If False, 
nothing was changed; if True, at least  one value was changed.
%END REM changed = False Dim SearchValue As String, ReplacementValue As String Dim x As Integer, i As Integer, L As Integer If action = "TWEAK" Then SearchValue = "," ReplacementValue = Chr(0130) Elseif action = "UNTWEAK" Then SearchValue = Chr(0130) ReplacementValue = "," Else Messagebox "CommaSubstitute called with invalid argument = " & action & " Please contact Support.", 48, "System Error" Exit Sub End If Forall valu In array L = Len(valu) For i = 1 To L If Mid(valu, i, 1) = SearchValue Then Mid(valu, i, 1) = ReplacementValue changed = True End If Next End Forall End Sub

This was first published in January 2003

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.