I have a series of job numbers like this
K3444-
K5633-
3434-
3434- A
3434- B
M3456-
I need to count the characters left of the dash and then add a leading space to those that only have 4 characters. It should look something like this:
K3444-
K5633-
3434-
3434- A
3434- B
M3456-
So far (with the help of another thread on this forum) I have been able to figure out how to count all the characters in the textbox and add the spacer with this:
How do I modify this to count only the characters left of the - (dash)?VB Code:
Dim strCharCount As String = txtJobNumber.Text strCharCount = RTrim(strCharCount) Dim iLength As Integer = strCharCount.Length If iLength >= 5 Then strCharCount = strCharCount ElseIf iLength = 4 Then strCharCount = " " & strCharCount ElseIf iLength <= 3 Then MsgBox("You must use a valid Job Number.", _ MsgBoxStyle.OKOnly, "Length Error!") txtJobName.Clear() txtJobNumber.Focus() Exit Sub End If




Reply With Quote