Solved

Formatting a Textbox

Posted on 2004-10-14
2
1,287 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

832 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