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. General Programming
  3. Windows Forms
  4. Function IIF in VB.net

Function IIF in VB.net

Scheduled Pinned Locked Moved Windows Forms
csharpdatabasetutorial
10 Posts 5 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.
  • T Offline
    T Offline
    tungcan5diop
    wrote on last edited by
    #1

    Hi All. in Vb.NET there is a function called IIF..how to do function IIF in SQL 2005.i want use IIF function from VB.net to sql 2005. thanhks for advance:confused:

    if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if

    M P A 3 Replies Last reply
    0
    • T tungcan5diop

      Hi All. in Vb.NET there is a function called IIF..how to do function IIF in SQL 2005.i want use IIF function from VB.net to sql 2005. thanhks for advance:confused:

      if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      Wrong forum, you missed on both vounts, this is neither a VB nor a windows form questions. It is a SQL questions. And the answer is - there is no equivalent TSQL function to IIF. You would have to use nested if statements.

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • T tungcan5diop

        Hi All. in Vb.NET there is a function called IIF..how to do function IIF in SQL 2005.i want use IIF function from VB.net to sql 2005. thanhks for advance:confused:

        if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Wrong forum, and VB.NET does not have IIF, AFAIK :|

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

        A 1 Reply Last reply
        0
        • P Paul Conrad

          Wrong forum, and VB.NET does not have IIF, AFAIK :|

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

          A Offline
          A Offline
          AlexeiXX3
          wrote on last edited by
          #4

          Are you sure VB.Net doesnt have IIF?? Thas weird, cause ive been using it lately, but i guess it must be my VS version

          Alexei Rodriguez

          P 1 Reply Last reply
          0
          • A AlexeiXX3

            Are you sure VB.Net doesnt have IIF?? Thas weird, cause ive been using it lately, but i guess it must be my VS version

            Alexei Rodriguez

            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #5

            It's there in VS2008. Learned something new today. I always thought it was just a VBA thing :-O

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

            A 1 Reply Last reply
            0
            • P Paul Conrad

              It's there in VS2008. Learned something new today. I always thought it was just a VBA thing :-O

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

              A Offline
              A Offline
              AlexeiXX3
              wrote on last edited by
              #6

              Its good to know it is in VS2008 too since its a great function Too bad VB doesnt have ?? as c# IIF is available in VS2005 too and maybe since 2003

              Alexei Rodriguez

              G 1 Reply Last reply
              0
              • T tungcan5diop

                Hi All. in Vb.NET there is a function called IIF..how to do function IIF in SQL 2005.i want use IIF function from VB.net to sql 2005. thanhks for advance:confused:

                if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if

                A Offline
                A Offline
                AlexeiXX3
                wrote on last edited by
                #7

                Use CASE statements in SQL to simulate IFF

                SELECT Category =
                CASE type
                WHEN 'popular_comp' THEN 'Popular Computing'
                WHEN 'mod_cook' THEN 'Modern Cooking'
                WHEN 'business' THEN 'Business'
                WHEN 'psychology' THEN 'Psychology'
                WHEN 'trad_cook' THEN 'Traditional Cooking'
                ELSE 'Not yet categorized'
                END,
                price AS Price
                FROM titles

                Alexei Rodriguez

                T 1 Reply Last reply
                0
                • A AlexeiXX3

                  Use CASE statements in SQL to simulate IFF

                  SELECT Category =
                  CASE type
                  WHEN 'popular_comp' THEN 'Popular Computing'
                  WHEN 'mod_cook' THEN 'Modern Cooking'
                  WHEN 'business' THEN 'Business'
                  WHEN 'psychology' THEN 'Psychology'
                  WHEN 'trad_cook' THEN 'Traditional Cooking'
                  ELSE 'Not yet categorized'
                  END,
                  price AS Price
                  FROM titles

                  Alexei Rodriguez

                  T Offline
                  T Offline
                  tungcan5diop
                  wrote on last edited by
                  #8

                  thanks your suggetion.Thanks so much :-D

                  if you cound not try then msgbox("you will lose") else msgbox("you can change yourself") end if

                  1 Reply Last reply
                  0
                  • A AlexeiXX3

                    Its good to know it is in VS2008 too since its a great function Too bad VB doesnt have ?? as c# IIF is available in VS2005 too and maybe since 2003

                    Alexei Rodriguez

                    G Offline
                    G Offline
                    Gideon Engelberth
                    wrote on last edited by
                    #9

                    IIF has always been available to VB. The problem is that it is a function not an operator, which of course makes it nearly worthless. Starting with VS2008/VB9, the If operator was added that can be used to do the same thing as both the ?: and ?? operators depending on the number of arguments you pass. condition ? truevalue : falsevalue becomes If(condition, truevalue, falsevalue) condition ?? nullvalue becomes If(condition, nullvalue)

                    A 1 Reply Last reply
                    0
                    • G Gideon Engelberth

                      IIF has always been available to VB. The problem is that it is a function not an operator, which of course makes it nearly worthless. Starting with VS2008/VB9, the If operator was added that can be used to do the same thing as both the ?: and ?? operators depending on the number of arguments you pass. condition ? truevalue : falsevalue becomes If(condition, truevalue, falsevalue) condition ?? nullvalue becomes If(condition, nullvalue)

                      A Offline
                      A Offline
                      AlexeiXX3
                      wrote on last edited by
                      #10

                      Good to know Thanks

                      Alexei Rodriguez

                      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