Solved

Formatting a Textbox

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How Complex Is This Java Course ? 9 93
parentbit challenge 3 72
groupSumClump challenge 9 98
wordmultiple challenge 12 117
This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now