Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Restricting Characters within a User Form

How does one restrict certain characters from being entered into a user form
TextBox?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Restricting Characters within a User Form

Try some code like the following.


Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim C As String
With Me.TextBox1
If Len(.Text) = 0 Then
Exit Sub
End If
C = Right(.Text, 1)
Select Case C
Case "a", "b", "c"
' allowed
Case Else
' anything else is prohibited
.Text = Left(.Text, Len(.Text) - 1)
End Select
End With
End Sub


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Wed, 19 Nov 2008 13:00:05 -0800, DarnTootn
wrote:

How does one restrict certain characters from being entered into a user form
TextBox?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Restricting Characters within a User Form

I think with a few "tweaks" to it, this will work perfectly. Thanks again!!
If it weren't for folks like yourself that contribute to these discussion
groups I would never get anything done and would be spending my time in
professional training courses to get the same kind of information that I get
from this group. THANKS TO ALL !!

"Chip Pearson" wrote:

Try some code like the following.


Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim C As String
With Me.TextBox1
If Len(.Text) = 0 Then
Exit Sub
End If
C = Right(.Text, 1)
Select Case C
Case "a", "b", "c"
' allowed
Case Else
' anything else is prohibited
.Text = Left(.Text, Len(.Text) - 1)
End Select
End With
End Sub


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Wed, 19 Nov 2008 13:00:05 -0800, DarnTootn
wrote:

How does one restrict certain characters from being entered into a user form
TextBox?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Restricting Characters within a User Form

Again, Thank you to all those that contribute to this disscussion group.
THIS ONE WORKS GREAT THANKS CHIP!!!!!

"DarnTootn" wrote:

I think with a few "tweaks" to it, this will work perfectly. Thanks again!!
If it weren't for folks like yourself that contribute to these discussion
groups I would never get anything done and would be spending my time in
professional training courses to get the same kind of information that I get
from this group. THANKS TO ALL !!

"Chip Pearson" wrote:

Try some code like the following.


Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
Dim C As String
With Me.TextBox1
If Len(.Text) = 0 Then
Exit Sub
End If
C = Right(.Text, 1)
Select Case C
Case "a", "b", "c"
' allowed
Case Else
' anything else is prohibited
.Text = Left(.Text, Len(.Text) - 1)
End Select
End With
End Sub


Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Wed, 19 Nov 2008 13:00:05 -0800, DarnTootn
wrote:

How does one restrict certain characters from being entered into a user form
TextBox?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting user to enter the date in a particular format only ! sajjadhyder Excel Discussion (Misc queries) 1 January 3rd 08 05:25 PM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
restricting use of certain characters Rob Excel Discussion (Misc queries) 4 June 8th 06 01:07 AM
Restricting Multi-user access [email protected] Excel Worksheet Functions 0 June 17th 05 03:03 PM
User Form Still Trying mully New Users to Excel 3 May 26th 05 06:30 PM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"