Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Another fine gem mined from the codebase

Another fine gem mined from the codebase

Scheduled Pinned Locked Moved The Weird and The Wonderful
rubydatabasehelpcareer
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wes Jones
    wrote on last edited by
    #1
    Private Function SomeCrappyCode(lsDate As String) As Long
      On Error GoTo ErrorHandler
    
      Dim llRetval
      Dim llPosition As Long
      
      'Updates the US Month Name in SQL Date to Locale
      'Month Name in Locale Language
      
      llPosition = InStr(lsDate, "Jan")
      If llPosition > 0 Then
        lsDate = Left(lsDate, llPosition - 1) & Format(DateSerial(98, 1, 1), "MMM") & right(lsDate, Len(lsDate) - 3)
        llRetval = True
        Exit Function
      End If
      
      'Copy & paste the above code block 11 more times for Feb...December  
    
      mlUpdateMonthStringLocale = llRetval
        
    Exit Function
    ErrorHandler:
    
      WriteErrorLogEntry Err.number, "SomeCrappyCode", Err.description
      Exit Function
      Resume
    
    End Function
    
    J L 2 Replies Last reply
    0
    • W Wes Jones
      Private Function SomeCrappyCode(lsDate As String) As Long
        On Error GoTo ErrorHandler
      
        Dim llRetval
        Dim llPosition As Long
        
        'Updates the US Month Name in SQL Date to Locale
        'Month Name in Locale Language
        
        llPosition = InStr(lsDate, "Jan")
        If llPosition > 0 Then
          lsDate = Left(lsDate, llPosition - 1) & Format(DateSerial(98, 1, 1), "MMM") & right(lsDate, Len(lsDate) - 3)
          llRetval = True
          Exit Function
        End If
        
        'Copy & paste the above code block 11 more times for Feb...December  
      
        mlUpdateMonthStringLocale = llRetval
          
      Exit Function
      ErrorHandler:
      
        WriteErrorLogEntry Err.number, "SomeCrappyCode", Err.description
        Exit Function
        Resume
      
      End Function
      
      J Offline
      J Offline
      Jeroen De Dauw
      wrote on last edited by
      #2

      Ingenious solution to the problem indeed. Obviously it'd be better of with a switch statement though :laugh:

      Jeroen De Dauw --- Forums ; Blog ; Wiki --- 70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!

      1 Reply Last reply
      0
      • W Wes Jones
        Private Function SomeCrappyCode(lsDate As String) As Long
          On Error GoTo ErrorHandler
        
          Dim llRetval
          Dim llPosition As Long
          
          'Updates the US Month Name in SQL Date to Locale
          'Month Name in Locale Language
          
          llPosition = InStr(lsDate, "Jan")
          If llPosition > 0 Then
            lsDate = Left(lsDate, llPosition - 1) & Format(DateSerial(98, 1, 1), "MMM") & right(lsDate, Len(lsDate) - 3)
            llRetval = True
            Exit Function
          End If
          
          'Copy & paste the above code block 11 more times for Feb...December  
        
          mlUpdateMonthStringLocale = llRetval
            
        Exit Function
        ErrorHandler:
        
          WriteErrorLogEntry Err.number, "SomeCrappyCode", Err.description
          Exit Function
          Resume
        
        End Function
        
        L Offline
        L Offline
        Lutoslaw
        wrote on last edited by
        #3

        I am not sure how it works in VB exactly, but in a normal language this code would alter local variables lsDate and llRetval without affecting the outside world. So, this function does virtually nothing. Am I right?

        Greetings - Jacek

        W 1 Reply Last reply
        0
        • L Lutoslaw

          I am not sure how it works in VB exactly, but in a normal language this code would alter local variables lsDate and llRetval without affecting the outside world. So, this function does virtually nothing. Am I right?

          Greetings - Jacek

          W Offline
          W Offline
          Wes Jones
          wrote on last edited by
          #4

          in this case, the incoming parameter defaults to "ByRef", lRetVal defaults to Variant, and the return value is only set when the line of code "ThisFunctionName = aValue", so luckily it sets the lsDate param, but the return value is never set 'cause the author was retarded

          L 1 Reply Last reply
          0
          • W Wes Jones

            in this case, the incoming parameter defaults to "ByRef", lRetVal defaults to Variant, and the return value is only set when the line of code "ThisFunctionName = aValue", so luckily it sets the lsDate param, but the return value is never set 'cause the author was retarded

            L Offline
            L Offline
            Lutoslaw
            wrote on last edited by
            #5

            Wes Jones wrote:

            the return value is never set 'cause the author was retarded

            ...

            Greetings - Jacek

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups