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. 5 in a 1 to 10 range

5 in a 1 to 10 range

Scheduled Pinned Locked Moved The Weird and The Wonderful
16 Posts 10 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.
  • L Luc 648011

    so one couldn't do any better in VB? :)

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

    C#:

    string[] codes = { "bad", "good" };
    int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

    Now do the VB one! :)

    xacc.ide - now with TabsToSpaces support
    IronScheme - 1.0 beta 2 - out now!
    ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

    modified on Wednesday, April 15, 2009 11:05 AM

    0 L P D V 5 Replies Last reply
    0
    • L leppie

      C#:

      string[] codes = { "bad", "good" };
      int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

      Now do the VB one! :)

      xacc.ide - now with TabsToSpaces support
      IronScheme - 1.0 beta 2 - out now!
      ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

      modified on Wednesday, April 15, 2009 11:05 AM

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #6

      Um, the Array.IndexOf method looks a little off. Shouldn't it be Array.IndexOf(codes, "bad")?

      L 1 Reply Last reply
      0
      • L leppie

        C#:

        string[] codes = { "bad", "good" };
        int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

        Now do the VB one! :)

        xacc.ide - now with TabsToSpaces support
        IronScheme - 1.0 beta 2 - out now!
        ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

        modified on Wednesday, April 15, 2009 11:05 AM

        L Offline
        L Offline
        Luc 648011
        wrote on last edited by
        #7

        I wouldn't know where to start, except for tossing out all those fancy brackets and semi-colons... :)

        1 Reply Last reply
        0
        • L leppie

          C#:

          string[] codes = { "bad", "good" };
          int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

          Now do the VB one! :)

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 beta 2 - out now!
          ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

          modified on Wednesday, April 15, 2009 11:05 AM

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #8

          Leppie, I think you need to step away from the computer and get some rest.

          1 Reply Last reply
          0
          • 0 0x3c0

            Um, the Array.IndexOf method looks a little off. Shouldn't it be Array.IndexOf(codes, "bad")?

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #9

            Yeah, now fixed, my brain needs rest now! :sigh:

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 beta 2 - out now!
            ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

            N 1 Reply Last reply
            0
            • A adgonz

              If the worst horror you could find in my company is ranked 10 and a moderate horror is ranked 1, I think I could rank this with 5:

                  Dim key As String
                  key= "N"
                  key= "linatipedi=" + "'" + key+ "'"
                  Dim rR As DataRow() = t.Select(key)
                  If rR.Length() = 0 Then
                      i = 0
                  Else
                      Try
                          For Each r In rR
                              i += 1
                          Next r
                      Catch
                          If i = 0 Then
                              Return True
                          Else
                              Return False
                          End If
                      End Try
                  End If
                  If i = 0 Then
                      Return True
                  Else
                      Return False
                  End If
              
              I Offline
              I Offline
              Ian Shlasko
              wrote on last edited by
              #10

              Oh, come on... Even VB can do this in one line plus exception handling...

              Try
              Return t.Select("linatipedi='N'").Length = 0 // *resists urge to type two ='s*
              Catch
              Return False
              End Try

              Man, if this is a 5, I'd really hate to see a 10... Translation: Post one of the 10's! Heheh

              A R 2 Replies Last reply
              0
              • L leppie

                Yeah, now fixed, my brain needs rest now! :sigh:

                xacc.ide - now with TabsToSpaces support
                IronScheme - 1.0 beta 2 - out now!
                ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                N Offline
                N Offline
                notmasteryet
                wrote on last edited by
                #11

                leppie wrote:

                Yeah, now fixed, my brain needs rest now!

                ...too much VB code for that one

                1 Reply Last reply
                0
                • I Ian Shlasko

                  Oh, come on... Even VB can do this in one line plus exception handling...

                  Try
                  Return t.Select("linatipedi='N'").Length = 0 // *resists urge to type two ='s*
                  Catch
                  Return False
                  End Try

                  Man, if this is a 5, I'd really hate to see a 10... Translation: Post one of the 10's! Heheh

                  A Offline
                  A Offline
                  adgonz
                  wrote on last edited by
                  #12

                  Ian Shlasko wrote:

                  Translation: Post one of the 10's! Heheh

                  A 6 or 7 (I'm not sure) is this code is from a function that should never had been called / written, so your better implementation is useless.

                  1 Reply Last reply
                  0
                  • L leppie

                    C#:

                    string[] codes = { "bad", "good" };
                    int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

                    Now do the VB one! :)

                    xacc.ide - now with TabsToSpaces support
                    IronScheme - 1.0 beta 2 - out now!
                    ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                    modified on Wednesday, April 15, 2009 11:05 AM

                    D Offline
                    D Offline
                    dybs
                    wrote on last edited by
                    #13

                    Doesn't this actually gives a rating of 0 ("bad" is the first element, and 0 * anything = 0)? Dybs

                    1 Reply Last reply
                    0
                    • I Ian Shlasko

                      Oh, come on... Even VB can do this in one line plus exception handling...

                      Try
                      Return t.Select("linatipedi='N'").Length = 0 // *resists urge to type two ='s*
                      Catch
                      Return False
                      End Try

                      Man, if this is a 5, I'd really hate to see a 10... Translation: Post one of the 10's! Heheh

                      R Offline
                      R Offline
                      Rob Grainger
                      wrote on last edited by
                      #14

                      Ian Shlasko wrote:

                      // *resists urge to type two ='s*

                      'Couldn't resist the temptation to use C++-style comments though.

                      I 1 Reply Last reply
                      0
                      • R Rob Grainger

                        Ian Shlasko wrote:

                        // *resists urge to type two ='s*

                        'Couldn't resist the temptation to use C++-style comments though.

                        I Offline
                        I Offline
                        Ian Shlasko
                        wrote on last edited by
                        #15

                        Ack! I totally missed that... Well, shows how much I've tried to get away from VB.

                        1 Reply Last reply
                        0
                        • L leppie

                          C#:

                          string[] codes = { "bad", "good" };
                          int rating = Array.IndexOf(codes, "bad") * 5; // use 5 star system

                          Now do the VB one! :)

                          xacc.ide - now with TabsToSpaces support
                          IronScheme - 1.0 beta 2 - out now!
                          ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))

                          modified on Wednesday, April 15, 2009 11:05 AM

                          V Offline
                          V Offline
                          Vozzie2
                          wrote on last edited by
                          #16

                          Looks like VB is scoring better,...

                          Dim codes() As String = New String(){"bad", "good"}
                          Dim rating As Integer = (Array.IndexOf(codes, "bad") + 1) * 5

                          It feels good to learn and achieve

                          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