atw: Re: stripping spaces etc from a variable in VBA

  • From: "Elizabeth Fullerton" <Elizabeth.Fullerton@xxxxxxxxxx>
  • To: <austechwriter@xxxxxxxxxxxxx>
  • Date: Thu, 9 Oct 2003 11:06:35 +1000

Yeah, I haven't had a big chance to look at this yet, but I reckon that
if you go through the string char by char, testing against the
alphanumeric ascii values, and copy them to another string if they are
within the range and not if they aren't, that would work. There might be
a tidier way - there might be an isNum or isAlpha function, but then
again, maybe I'm thinking of C.

If it's not screeds of text and you don't care too much about
performance, a simple compare thingy against each char might be the go.



-----Original Message-----
From: jzolin@xxxxxxxxxxxxxxx [mailto:jzolin@xxxxxxxxxxxxxxx]=20
Sent: Thursday, 9 October 2003 10:08 AM
To: austechwriter @ freelists . org
Subject: atw: Re: stripping spaces etc from a variable in VBA


Stripping spaces n other characters from text string.

Heya Mel,=20

been a while since I bounced around in VBA myself (Vic Bitter for
Applications,=20
Yeah!) so no code snippets for you I'm afraid,

However
You should be able to use the "inString" function and len(str$) to go
through the=20
text srtring character by character.  you can then do a test on the
ascii value of=20
each character, to see if it falls within the range of capital letters
or lower case=20
letters.
build another string as you go through the initial textstring, only
using those=20
characters you have checked and approved (I think using the cat function

(concatenate?))

After you have gone through each character you will have a new string
containing=20
only those characters you want.

hope this helps, prolly a bit vague, but might prompt your memories...

Good Luck

Joe Z.



> melanie.kendell <melanie.kendell@xxxxxxxxxxx> wrote:
>=20
>=20
> Hi VBA gurus
>=20
> I remember doing this before (I also remember I had trouble figuring
> it out last time) but I'm having a mental blank.
>=20
> What I want to do is this:
>=20
> Take the text from a selection and place it in a variable.
>=20
> Strip the spaces, question marks, etc, from the variable and pass the
> result to another variable.
>=20
> I do not want the selected text in the document to change.
>=20
> Any ideas?
>=20
> -Melanie
>                                               =09
              =20
>=20
>=20
> **************************************************
> To post a message to austechwriter, send the message to
> austechwriter@xxxxxxxxxxxxxx
>=20
> To subscribe to austechwriter, send a message to
> austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject
> field.
>=20
> To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx
> with "unsubscribe" in the Subject field.
>=20
> To search the austechwriter archives, go to
> www.freelists.org/archives/austechwriter
>=20
> To contact the list administrator, send a message to
> austechwriter-admins@xxxxxxxxxxxxx
> **************************************************

**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject
field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx
with "unsubscribe" in the Subject field.

To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************


********** CAUTION - Disclaimer **********
This message may contain privileged and confidential
information. If you are not the intended recipient of this
message (or responsible for delivery of the message to
such person) you are hereby notified that any use,
dissemination, distribution or reproduction of this message
is prohibited. If you have received this message in error,
you should destroy it and kindly notify the sender by reply
e-mail. Please advise immediately if you or your employer
do not consent to Internet e-mail for messages of this kind.
Opinions, conclusions and other information in this
message that do not relate to the official business of
Expert Information Services Pty Ltd ("The Company")
shall be understood as neither given nor endorsed by it.

The Company advises that this e-mail and any attached
files should be scanned to detect viruses. The Company
accepts no liability for loss or damage (whether caused
by negligence or not) resulting from the use of any
attached files.
**EIS******** End of Disclaimer **********

**************************************************
To post a message to austechwriter, send the message to 
austechwriter@xxxxxxxxxxxxxx

To subscribe to austechwriter, send a message to 
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.

To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with 
"unsubscribe" in the Subject field.

To search the austechwriter archives, go to 
www.freelists.org/archives/austechwriter

To contact the list administrator, send a message to 
austechwriter-admins@xxxxxxxxxxxxx
**************************************************

Other related posts: