LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Limiting number of characters in textbox

I received help previously on this problem which was brilliant but I missed a
problem that occurs. When entering the numbers from right side of text box
you can continue to enter numbers as you like with no stop. When the person
enters the 5th number it must stop the entry and show message cannot
procedure further and then move to next textbox. The code to date is below.
Any assistance would be greatly appreciated.

Private Sub txtInvClaim_Change()
Dim i As Long
Dim s As String
Dim ba() As Byte ' byte-array
Static bExit As Boolean

If Not bExit Then
s = UCase(Me.txtInvClaim.Text)
ba = s
s = ""
For i = 0 To UBound(ba) Step 2
If ba(i + 1) = 0 Then
Select Case ba(i)
Case 48 To 57
' digits 0-9
s = s & Chr(ba(i))
Case 65 To 90
'letters only in 1st 2 characters
If i <= 3 Then
s = s & Chr(ba(i))
End If
End Select
End If
Next
If Len(s) 1 Then
s = Left$(s, 2) & "/" & Right$("00000" & Mid$(s, 3, Len(s) - 2), 5)
End If
If txtInvClaim.Text < s Then
bExit = True
txtInvClaim.Text = s
End If
End If
bExit = False
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1

 
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
Limiting the number of characters in a cell smartgal Excel Discussion (Misc queries) 5 September 10th 09 11:59 PM
Limiting a Column to "X" Number of Characters Wayne Excel Discussion (Misc queries) 2 June 26th 08 12:35 AM
Limiting a Column to "X" Number of Characters Wayne Excel Discussion (Misc queries) 3 June 25th 08 08:39 PM
Textbox: Number of Characters Bill[_30_] Excel Programming 1 July 2nd 06 10:12 PM
Limiting the number of characters in a cell. How? caliskier Excel Discussion (Misc queries) 3 January 12th 06 04:50 PM


All times are GMT +1. The time now is 01:38 PM.

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

About Us

"It's about Microsoft Excel"