473,654 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.C heckedItems.Cou nt > 0, Button1.Enabled = True,
Button1.Enabled = False)

This works

If Listview1.Check edItems.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...ELS E

Thanks

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


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.Chec kedItems.Count > 0)

Hope this helps
Jay

"Charles May" <qu*********@ho tmail.com> wrote in message
news:yB4Fb.1018 64$8y1.312337@a ttbi_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.C heckedItems.Cou nt > 0, Button1.Enabled = True,
Button1.Enabled = False)

This works

If Listview1.Check edItems.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...ELS E

Thanks

Charlie

Jul 21 '05 #3
Thanks Mattias.

It's working now with your help

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


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
6080
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 just not work at all, much to my frustration. :-( I'm trying to write a simple calculation and it just plain outputs wrong information. Something like this: function calculateValue(kWh) { dollar_amount = kWh * .033;
15
5136
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 calls to a script which parses the url and produces requested pages. It works fine with browsers, but when I try to validate the page I get a 404 error - which bewilders me, because I thought Apache does the redirection internally without sending...
2
3549
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 system that will identify where the users are coming from based on their IP address, and for this project I would really like to replace the English country list with a list of the country in the local language. I'm been around on
7
1564
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 Integer = 0 To LinkResults.Length - 1 With MyCurrentClass.SqlCmd_Insert_LinkVB .CommandType = System.Data.CommandType.StoredProcedure
7
2616
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 crash with an exception report (I've not got the details of the error, but I'm working on that now!). I'm trying to reproduce the circumstances by simulating a typical batch of user tasks on my pc and monitoring whats happening. I'm guessing it's...
160
4655
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 prof. would post program questions and the solutions online. For practice I would try to do the problems. I would reach to a certain point in the code, for example as far as error trapping, but when the loop arrives, like knowing whether to use...
39
19617
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) What's the difference between these 3 statements: (i) memcpy(&b, &KoefD, n); // this works somewhere in my code
7
2157
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 need deep copy and I believe I'm doing that in my constructors. Can someone help me see what I'm missing out? Here is my code. typedef boost::shared_ptr<FactorFactorPtr; enum FactorTypeT
5
1994
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: *************************************************************************************************************** { ........................... PrintTimeSpanProblem(); device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams); PrintTimeSpanProblem();
0
2183
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 problems later). Apparently Point is a struct, a value type, and it does not behave like a classic structure (in my mind's eye, and see below). Traditionally I think of a classic structure as simply an object where every member is public. But with...
0
8379
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8294
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2719
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.