[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Adding spaces into a variable

Peter

12/15/2006 4:10:00 PM

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

4 Answers

Bob Phillips

12/15/2006 4:34:00 PM

0

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" <peter.a.rich@googlemail.com> wrote in message
news:1166198996.149572.136690@73g2000cwn.googlegroups.com...
>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
>


Peter

12/15/2006 4:58:00 PM

0

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

Bob Phillips

12/15/2006 5:30:00 PM

0

Is your textbox on a userform?

Describe how it is not working please.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Peter" <peter.a.rich@googlemail.com> wrote in message
news:1166201885.499785.237800@j72g2000cwa.googlegroups.com...
> 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
>


Peter

12/18/2006 10:30:00 AM

0

Thanks for your help, it works fine now.

The code helped a lot!