473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Is there a problem with IIF or am I doing something wrong?

I have a listview which checkboxes containing items to invoice. The Create
Invoice button (button1) is disabled unless there are items checked.
However, I had to use an if..then..else statement to make it work. My
question is, why can I not get it to work using an IIF statement?

In the mouseup event of the listview I tried the following methods to
achieve the result.
This doesn't work
IIF(Listview1.CheckedItems.Count > 0, Button1.Enabled = True,
Button1.Enabled = False)

This works

If Listview1.CheckedItems.Count > 0 Then
Button1.Enabled = True
Else
Button1.Enabled = False
End If

I'm just curious if I did something wrong trying to use IIF instead of
IF...THEN...ELSE

Thanks

Charlie
Jul 21 '05 #1
3 1355
Charles,
I'm just curious if I did something wrong trying to use IIF instead of
IF...THEN...ELSE


IIF is not a built-in language statement, it's a function. And like
any other function, all the parameters you pass to it are evaluated,
and using = in that context performs comparison, not assignment.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Charles,
In addition to Mattias's comments, have you considered simply using:

Button1.Enabled = (Listview1.CheckedItems.Count > 0)

Hope this helps
Jay

"Charles May" <qu*********@hotmail.com> wrote in message
news:yB4Fb.101864$8y1.312337@attbi_s52...
I have a listview which checkboxes containing items to invoice. The Create
Invoice button (button1) is disabled unless there are items checked.
However, I had to use an if..then..else statement to make it work. My
question is, why can I not get it to work using an IIF statement?

In the mouseup event of the listview I tried the following methods to
achieve the result.
This doesn't work
IIF(Listview1.CheckedItems.Count > 0, Button1.Enabled = True,
Button1.Enabled = False)

This works

If Listview1.CheckedItems.Count > 0 Then
Button1.Enabled = True
Else
Button1.Enabled = False
End If

I'm just curious if I did something wrong trying to use IIF instead of
IF...THEN...ELSE

Thanks

Charlie

Jul 21 '05 #3
Thanks Mattias.

It's working now with your help

Charlie
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Charles,
I'm just curious if I did something wrong trying to use IIF instead of
IF...THEN...ELSE


IIF is not a built-in language statement, it's a function. And like
any other function, all the parameters you pass to it are evaluated,
and using = in that context performs comparison, not assignment.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eric Gibson | last post by:
I could have sworn this would be a FAQ, but it doesn't appear to be in there. You must get this all the time, or I'm just totally doing something wrong. Math with int's and floats appears to...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
2
by: Zyron | last post by:
Hello! I'm developing a web page that has a goal of providing personal content, which means that all information should be written in their own language. I'm about to finish my Geo targeting...
7
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As...
7
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just...
160
by: RG | last post by:
Greetings friends, This semester I have started a course in C programming. I was moving along fine until I reached to the topic of loops (feeling embarrassed among you elite programmers). My...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
7
by: pallav | last post by:
I'm having some trouble with my copy constructor. I've tried using gdb to find the bug, but it seg faults in the destructor. I'm not able to see what I'm doing wrong. Since I'm using pointers, I...
5
by: Vibhesh | last post by:
I am facing problem with TimeSpan structure when DirectX is used. Following is the sample code that causes the problem: ...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.