Solved

Formatting a Textbox

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
This is an explanation of a simple data model to help parse a JSON feed
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now