• Normalize WBS Function Acting Strange (A2003 SP2)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Normalize WBS Function Acting Strange (A2003 SP2)

    Author
    Topic
    #429979

    The following function is used to convert a WBS string to normalize it such that all levels other then the first are two characters. For example,
    C.1.2.4 is normalized to C.01.02.04, C.12.2 is normalized to C.12.02 and so on.

    C.12.1.2.12.1.1.1.1P normalizes to C.12.01.02.12.01.01.01.01 The function is below. Any ideas on why this is happening? The only recent change is that we upgraded from A2K to A2003.

    Function NormWBS(txt As String) As String
    Dim ar() As String
    Dim i As Integer
    ar = Split(txt, “.”)
    NormWBS = ar(0)
    For i = 1 To UBound(ar)
    NormWBS = NormWBS & “.” & Format(ar(i), “00”)
    Next i
    End Function

    The following was added at 1430

    Interesting that the below string ending in P doesn’t work but the one ending in Y does?

    C.12.1.2.12.1.4.1.1Y Normalizes correctly to C.12.01.02.12.01.04.01.1Y, but

    C.12.1.2.12.1.4.1.1P normalized incorrectly to C.12.01.02.12.01.04.01.01

    The following was added at 1441

    1P in any part of the string converts to 01 however P1 converts correctly to P1. Interesting. It appears that only 1P fails as 1W, 1X, 1Y, all work properly. Im stumped.

    Viewing 2 reply threads
    Author
    Replies
    • #1002748

      It doesn’t take 1P as a + sign, does it?

      This really is a guess.

    • #1002757

      I wonder if the format(…) is trying to format a number, and getting confused? Try substituting
      iif(len(ar(i))=1,”0″,””) & ar(i)
      for your format(…) call.

    • #1002764

      “1P” gets interpreted as 1:00 PM = 0.54166666… This gets rounded and formatted to 01.
      Similarly, “3A” would be interpreted as 3:00 AM = 0.125. This gets rounded and formatted to 00.
      Try this version:

      Function NormWBS(txt As String) As String
      Dim ar() As String
      Dim i As Integer
      ar = Split(txt, “.”)
      NormWBS = ar(0)
      For i = 1 To UBound(ar)
      If IsNumeric(ar(i)) Then
      NormWBS = NormWBS & “.” & Format(ar(i), “00”)
      Else
      NormWBS = NormWBS & “.” & ar(i)
      End If
      Next i
      End Function

      • #1003544

        Hans,

        Thanks once again. I would never have guessed the time format. thumbup

        Thanks to others for your suggestions as well.

    Viewing 2 reply threads
    Reply To: Normalize WBS Function Acting Strange (A2003 SP2)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: