Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Formatting a Textbox

Posted on 2006-10-27
3
Medium Priority
?
203 Views
Last Modified: 2010-04-23
Hi all,

I have a textbox on my form and I would like the user to enter 4 numbers into it and have the textbox automatically format it to xx/xx as they are typing. I have tried using the below code but when I do once the first two numbers have been typed the cursor is moved back to the start of the box rather than after the "/"

If txtboxExp.Text.Length = 2 Then
       txtboxExp.Text = txtboxExp.Text & "/"
End If

Can someone let me know and easy way of creating a custom format for a textbox like this.
Thanks
0
Comment
Question by:kiranboi
[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
3 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 2000 total points
ID: 17818888
Try this:

            If txtboxExp.Text.Length = 2 Then
                  txtboxExp.Text = txtboxExp.Text & "/"
                  txtboxExp.SelectionStart = txtboxExp.Text.Length
            End If
0
 

Author Comment

by:kiranboi
ID: 17818927
Perfect.

Thanx
0
 
LVL 5

Expert Comment

by:xersoft
ID: 17818938
If you are using .net 2.0 you can use the masked edit textbox and set the mask to "00/00" Does that provide what you are after?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

660 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