PC Review


Reply
Thread Tools Rate Thread

Adding spaces into a variable

 
 
Peter
Guest
Posts: n/a
 
      15th Dec 2006
I have a problem!

I am writing a macro where the user pastes in a 16 digit number into a
text box on a user form.
This then becomes a variable (long).

I need the macro to edit this variable by placing a space after the
4th, 8th and 12th number.

ie, from this: ################ to this: #### #### #### ####.

Is this possible?

Thanks,

Peter

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      15th Dec 2006
Peter,

If you want to embed spaces, it can't go into a Long variable, it will have
to be a String.

With Me.TextBox1
sVar = Format(.text,"0000 0000 0000 0000"))
End With
--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a problem!
>
> I am writing a macro where the user pastes in a 16 digit number into a
> text box on a user form.
> This then becomes a variable (long).
>
> I need the macro to edit this variable by placing a space after the
> 4th, 8th and 12th number.
>
> ie, from this: ################ to this: #### #### #### ####.
>
> Is this possible?
>
> Thanks,
>
> Peter
>



 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      15th Dec 2006
Bob,

You are right, it is a string. Thanks for the code but it is still not
working. I am not sure what it is, can you help?

Thanks,

Peter

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      15th Dec 2006
Is your textbox on a userform?

Describe how it is not working please.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Peter" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Bob,
>
> You are right, it is a string. Thanks for the code but it is still not
> working. I am not sure what it is, can you help?
>
> Thanks,
>
> Peter
>



 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      18th Dec 2006
Thanks for your help, it works fine now.

The code helped a lot!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Needed - Truncate extra spaces at end of variable text len Roibn Taylor Microsoft Excel Misc 1 4th Nov 2008 02:26 PM
Delete Variable spaces at beginning of a range gmunro Microsoft Excel Programming 4 21st Aug 2007 02:26 PM
Re: how do I insert a variable amount of blank spaces in a formula? Dave Peterson Microsoft Excel Worksheet Functions 0 14th Jan 2007 10:36 PM
evaluate a variable to see if it is 'empty' or if it contains just 'spaces'... Gary Microsoft Access 7 28th Nov 2005 11:50 AM
RE: Can I extract part of a variable length text field based on spaces =?Utf-8?B?T2Zlcg==?= Microsoft Access 0 14th Sep 2005 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 AM.