Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

Abbreviations

Hi I have run into a situation where I need to make sure that a string variable I have contains less then 30 characters.  In this string variable is names of Mutual Fund companies.  If the name is longer then 30 then I need to be able to abbreviate the name.  I have some Replace() functions for the common words like "Financial", etc.  However looking at some legacy code written in VB3 I see a function Abbrev(), is this still supported and if so what does it do, and or is there a comparable function in VB6?  Thanks in advance for any help or comments.
0
Glowman
Asked:
Glowman
1 Solution
 
Anthony PerkinsCommented:
To my knowledge, no such function has ever existed natively in Visual Basic (even prior to VB3)

Anthony
0
 
justinhemphillCommented:
myAbbrev = Left(strLongString,30)
0
 
GlowmanAuthor Commented:
That would be an easy way to do it justinhemphill but unfortunately I need to maintain the name not just cut it off.  thanks though
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
rspahitzCommented:
If you have the VB3 source code, you'll probably find an Abbrev function somewhere in the code.  This should translate quite well into VB6.  If not, post it here and we'll help you.
0
 
GlowmanAuthor Commented:
I am sorry Abbrev() is not a global function but rather a multidimensional array that I didn't notice before.  Anyway does anyone have an logic to determine which characters to remove from a word to abbreviate it?  I would like to avoid hundreds of Replace() functions.
0
 
rspahitzCommented:
Typically, abbreviation rules are as follows:

* Remove all vowels except for any leading vowel
* Replace "ght" with "t"
* Truncate words after 1/2 of the number of syllables.
* Optionally add a period at the end of the modified word to indicate that it is an abbreviation

Ex.
"Quality" becomes "Qlty."
"Light" becomes "lt."
"Truncate" becomes "Trunc."

Obviously, abbreviated words can be misinterpreted since they can mean different things, such as "Thought" becoming "tht" which might be misinterpreted at "that".  

For these, you may want to build a database of common abbreviations which do not follow the above rules.

Add the entries to the DB, then have your abbrev routine first check the DB.  If the word exists, use the corresponding DB entry, otherwise continue with the above rules (and any more you deem appropriate.)

0
 
GlowmanAuthor Commented:
Thanks that was what I was looking for.  I am going to use the split function to seperate my words, do you think this is a good way to go about this?
0
 
rspahitzCommented:
I'm glad that works for you.  It obviously needs some refinements, but it sounds like you're well on your way.

>split

I'd say that's a very good way to start, but remember that if you split by "space" you'll get some words with punctuation that you need to figure out how to handle.  For example, commas ("example,"), periods ("handle."), question marks, and apostrophes ("you'll") each may need to be addressed separately, as well as "words" with numbers in them.

Your best bet is to do as you're thinking (split up the words) and see what results you get, then refine the algorithm to handle the exception cases.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now