Adding spaces into a variable

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

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,

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)
 
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
 
Is your textbox on a userform?

Describe how it is not working please.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top