Solved

Formatting a Textbox

Posted on 2004-10-14
2
1,319 Views
Last Modified: 2008-02-01
In an XL worksheet I have an assortment of values, both text and numeric...after a transfer of values occursand  a User Form is opened, certain of the UserForm fields are automatically filled in via an assortment of VBA routines...so far so good...

Here's my dilema...let's say in the first workbook, Sheet 1, cell A1, I have the value '07'...it successfully gets transfered to another workbook,Sheet2,  cell B1, as '07'...when the UserForm opens and fields are auto-updated, the value for the field is 7...i.e., NO leading 0 (zero)...I need the '07' rather than the '7' since a unique ID number is generated from this piece of info...Thoughts???

Thanks,
Ron
0
Comment
Question by:ronaldj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
tim102096 earned 125 total points
ID: 12309648
You need to treat "07" as a string, VB will automatically cut any front leading zeros unless its treated as a string. Maybe some of your code would help. If your using variableschange the integers or longs to strings, or however your transfering from the sheet to the form cast or extract the value as a string.
0
 

Author Comment

by:ronaldj
ID: 12309987
You stirred the proverbial "creative juices"...

I think my problem was breaking down the string (ddmmyyyy) from Ws1 into pieces into Ws2 (dd) , (mm), (yyyy) and then trying to refer...

here's what I came up with and seems to work:

Private Sub TextBox3_Change()
Dim Ws34 As Worksheet
Dim month As String
Set Ws34 = Sheets("Random")
month = Mid(Ws34.Cells(7, 7).Value, 3, 2)
TextBox3.Value = month
End Sub

Thanks for the "push"...

Ron
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Introduction to Processes
Starting up a Project

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question