PDA

View Full Version : Solved: UF textbox 8th character



blackie42
08-28-2009, 03:09 AM
Hi,

Would it be possible to force a user to make the 8th character in textbox (in a forced string of 9 characters) to input a either a 'P' or 'U'.

Any help with the coding much appreciated

thanks

dominicb
08-28-2009, 03:24 AM
Good morning blackie42

Would it be possible to force a user to make the 8th character in textbox to input a either a 'P' or 'U'.
Does something like this suffice (assumes your tectbox is called TextBox1) :
Private Sub TextBox1_Change()
If Not Mid(TextBox1.Value, 8, 1) = "P" And Not Mid(TextBox1.Value, 8, 1) = "U" Then
TextBox1.Value = Left(TextBox1.Value, 7)
End If
End Sub

HTH

DominicB

Bob Phillips
08-28-2009, 03:29 AM
Problem with that is if they type a P in position 8 and then some more, and step back and replace the P, it wipes out all of the rest.