Results 1 to 5 of 5
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Normalize WBS Function Acting Strange (A2003 SP2)

    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.
    Regards,

    Gary
    (It's been a while!)

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Normalize WBS Function Acting Strange (A2003 SP2)

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

    This really is a guess.

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    Edmonton, Alberta, Canada
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Normalize WBS Function Acting Strange (A2003 SP2)

    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.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Normalize WBS Function Acting Strange (A2003 SP2)

    "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

  5. #5
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Normalize WBS Function Acting Strange (A2003 SP2)

    Hans,

    Thanks once again. I would never have guessed the time format. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    Thanks to others for your suggestions as well.
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

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