Results 1 to 4 of 4

Thread: Count Characters left of a hyphen

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Count Characters left of a hyphen

    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:
    VB Code:
    1. Dim strCharCount As String = txtJobNumber.Text
    2.         strCharCount = RTrim(strCharCount)
    3.         Dim iLength As Integer = strCharCount.Length
    4.         If iLength >= 5 Then
    5.             strCharCount = strCharCount
    6.         ElseIf iLength = 4 Then
    7.             strCharCount = " " & strCharCount
    8.         ElseIf iLength <= 3 Then
    9.             MsgBox("You must use a valid Job Number.", _
    10.                 MsgBoxStyle.OKOnly, "Length Error!")
    11.             txtJobName.Clear()
    12.             txtJobNumber.Focus()
    13.             Exit Sub
    14.         End If
    How do I modify this to count only the characters left of the - (dash)?
    Last edited by BukHix; Jan 5th, 2004 at 02:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width