Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 12th, 2007, 04:41 AM
Authorized User
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default IIf

hi all :)

what is the use of IIf?

Reply With Quote
  #2 (permalink)  
Old June 12th, 2007, 11:31 AM
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

You really can find all of the answers to the basic questions you have been asking in VB Help...

IIf is a single-statement If for returning a value. It takes three arguments. If the first argument is true, it returns the 2nd argument. If the 1st argument is false, it returns the 3rd argument.
   Dim s as String

   s = IIf( (2 + 2) = 4, "It is True", "It is False")

   ' The above results in exactly the same result as the below.

   If (2 + 2) = 4 Then
      s = "It is True"
      s = "It is False"
   End If
Reply With Quote
  #3 (permalink)  
Old June 13th, 2007, 12:34 AM
Authorized User
Join Date: May 2007
Location: Chennai, Tamil Nadu, India.
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts

thank you very much Brian

Reply With Quote
  #4 (permalink)  
Old June 21st, 2007, 12:24 AM
Friend of Wrox
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

Well... actually, the value of the immediate if (IIf) is for use in an expression or as an argument being passed to a parameter of a procedure.

Note that IIf itself is a function which accepts 3 parameters and returns a value. Although it seems as if it is the same thing as a regular If...Else block, its real benefit is that it returns a value. Each argument itself can also be an expression, and this brings a great deal of power to this little intrinsic function. However, make sure all the arguments will be valid in all cases because all three arguments must be resolved before they are passed on to the IIf function, just like with any other function. In other words, regardless if the first argument is true or false, both the 2nd and 3rd arguments are going to be processed before their values are passed into the function.

Woody Z
How to use a forum to help solve problems
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with IIF thork1 Access 1 March 25th, 2008 06:42 AM
IIf problem Vince_421 Access 1 June 1st, 2006 11:35 AM
Query with IIF canmex Access 14 March 7th, 2006 03:07 AM
Question with iif Enoch Access 5 December 8th, 2005 04:36 PM

All times are GMT -4. The time now is 03:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.