Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Formatting a Textbox

Posted on 2004-10-14
2
Medium Priority
?
1,338 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 375 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Make the most of your online learning experience.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

972 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