msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pls help vb6.0

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise
Author Message
priyanka



Joined: 04 Oct 2007
Posts: 2

PostPosted: Wed Sep 27, 2006 8:57 am    Post subject: pls help vb6.0 Reply with quote

hi all,
im using a phone format as 111-111-1111. But during run time, if the
user changes that as 1123-1133-222222 this i don't want. I want to keep

the format fixed as 111-111-1111. If user is changing that then the "-"

sign is getting appended one after the another.
my code is:

Private Sub txtPhone_Change()


If Len(txtPhone.Text) = 4 Then
txtPhone.SelStart = 5
ElseIf Len(txtPhone.Text) = 3 Then
txtPhone.Text = txtPhone.Text + "-"
txtPhone.SelStart = 5
ElseIf Len(txtPhone.Text) = 7 Then
txtPhone.Text = txtPhone.Text + "-"
txtPhone.SelStart = 9
End If


End Sub


please help to modify this code

Archived from group: microsoft>public>vb>enterprise
Back to top
View user's profile Send private message
- CodeDoctor -



Joined: 04 Oct 2007
Posts: 1

PostPosted: Thu Nov 02, 2006 10:26 am    Post subject: RE: pls help vb6.0 Reply with quote

That is one way of accomplishing your goal, however there are a few other
techniques that may work better.

In the KeyDown event of the textbox you are using for the phone number, you
can
first check for the length of text is not 12 or greater.

If the length is 12, then always format it to ###-###-#### regardless of
what is
in there.

Or.

You can use the Mask Edit control. Goto Project / References / Components
and ensure it is added to your project, then use it in place of your text box.

Hope this helps.

- CodeDoctor -

"priyanka" wrote:

> hi all,
> im using a phone format as 111-111-1111. But during run time, if the
> user changes that as 1123-1133-222222 this i don't want. I want to keep
>
> the format fixed as 111-111-1111. If user is changing that then the "-"
>
> sign is getting appended one after the another.
> my code is:
>
> Private Sub txtPhone_Change()
>
>
> If Len(txtPhone.Text) = 4 Then
> txtPhone.SelStart = 5
> ElseIf Len(txtPhone.Text) = 3 Then
> txtPhone.Text = txtPhone.Text + "-"
> txtPhone.SelStart = 5
> ElseIf Len(txtPhone.Text) = 7 Then
> txtPhone.Text = txtPhone.Text + "-"
> txtPhone.SelStart = 9
> End If
>
>
> End Sub
>
>
> please help to modify this code
>
>

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Enterprise All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group