Dim i, j, k As Integer
i = 2 : j = 3
If i > j Then
k = i
Else
k = j
End If
is there a way to do something like this
k = (i > j) ? i : j
Thanks,
Rich 25 1205
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
: Dim i, j, k As Integer
: i = 2 : j = 3
:
: If i > j Then
: k = i
: Else
: k = j
: End If
:
: is there a way to do something like this
: k = (i > j) ? i : j
:
: Thanks,
: Rich
k = Iif(i > j, i, j)
Ralf
"Rich" <Ri**@discussions.microsoft.com> schrieb: Dim i, j, k As Integer i = 2 : j = 3
If i > j Then k = i Else k = j End If
is there a way to do something like this k = (i > j) ? i : j
'IIf'. However, note that 'IIf' is a function and thus both parts (true
part and false part) will get evaluated. In addition to that, casting will
be required if 'Option Strict' is turned on. VB 2005 will suppport a
generic version of 'IIf' which will work strongly-typed, which removes the
need of casting.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thanks. I just tried that, but having a problem when Option Strict is on -
says
"Option Strict does not allow implicit conversion of system object to integer"
I also tried
k = IIF(m > n, Ctype(m, Integer), Ctype(n, integer)
It didn't like that either. I also tried Imports Microsoft.VisualBasic, but
that didn't do it either. I don't want to turn off Option Strict. Is there
a way around this?
Thanks
"_AnonCoward" wrote: "Rich" <Ri**@discussions.microsoft.com> wrote in message news:92**********************************@microsof t.com... : Dim i, j, k As Integer : i = 2 : j = 3 : : If i > j Then : k = i : Else : k = j : End If : : is there a way to do something like this : k = (i > j) ? i : j : : Thanks, : Rich
k = Iif(i > j, i, j)
Ralf
Thanks. Yes. I was finally able to get my thing to work with casting like
this:
k = Ctype(IIf(m > n, m, n), Integer)
I had to put the Ctype outside of the IIf.
"Herfried K. Wagner [MVP]" wrote: "Rich" <Ri**@discussions.microsoft.com> schrieb: Dim i, j, k As Integer i = 2 : j = 3
If i > j Then k = i Else k = j End If
is there a way to do something like this k = (i > j) ? i : j
'IIf'. However, note that 'IIf' is a function and thus both parts (true part and false part) will get evaluated. In addition to that, casting will be required if 'Option Strict' is turned on. VB 2005 will suppport a generic version of 'IIf' which will work strongly-typed, which removes the need of casting.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
| "Option Strict does not allow implicit conversion of system object to
integer"
|
| I also tried
| k = IIF(m > n, Ctype(m, Integer), Ctype(n, integer)
have you tried:
k = directcast(iif(m>n, m, n), integer) ' you may need to cast all m's and
n's as well...i haven't tried it.
also...for the above...why not just:
k = math.max(m, n)
Rich, Is there a way around this?
Yes do not use it, it acts in another way (and sometimes strange) than in
other languages.
While this gives you the same and probably even an internal more efficient
result.
\\\
k = j
If i > j Then k=i
///
Cor
"Rich" <Ri**@discussions.microsoft.com> schrieb: "Option Strict does not allow implicit conversion of system object to integer"
I also tried k = IIF(m > n, Ctype(m, Integer), Ctype(n, integer)
\\\
Dim k, m, n As Integer
....
k = DirectCast(IIf(m > n, m, n), Integer)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb: While this gives you the same and probably even an internal more efficient result.
\\\ k = j If i > j Then k=i ///
Mhm... In this particular case I prefer:
\\\
Dim k, m, n As Integer
....
If m > n Then
k = m
Else
k = n
End If
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
herf...you're always a day late and a dollar short when handing out your
"knowledge". you posted "your" answer 10 minutes after copying *my*
answer...and you posted *your* warning about how the iif statement may
behave differently when option strict is on, again, 10 minutes after the op
said "the iif statement is behaving differently for me when option strict is
on".
you're a joke!
"herfried k. wagner [ASS]" is how it should read. you've been pulling this
shit for over 3 years now. whatever.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eJ***************@TK2MSFTNGP10.phx.gbl...
| "Rich" <Ri**@discussions.microsoft.com> schrieb:
| > "Option Strict does not allow implicit conversion of system object to
| > integer"
| >
| > I also tried
| > k = IIF(m > n, Ctype(m, Integer), Ctype(n, integer)
|
|
| \\\
| Dim k, m, n As Integer
| ...
| k = DirectCast(IIf(m > n, m, n), Integer)
| ///
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
| Mhm... In this particular case I prefer:
|
| \\\
| Dim k, m, n As Integer
| ...
| If m > n Then
| k = m
| Else
| k = n
| End If
| ///
i prefer not listing variables on a single line as it is hard to read and
maintain. but as for the code:
k = math.max(m,n)
if far more straight-forward and bloat-free...but then again, since i have
serious reservations about you actually being a professional programmer, i
shouldn't expect you to appreciate either of these two suggestions.
"" <a@b.com> schrieb: herf...you're always a day late and a dollar short when handing out your "knowledge". you posted "your" answer 10 minutes after copying *my* answer...and you posted *your* warning about how the iif statement may behave differently when option strict is on, again, 10 minutes after the op said "the iif statement is behaving differently for me when option strict is on".
From <URL:http://internet.ggu.edu/university_library/conf.html>:
"
Asynchronous Methods of communication do not require you to be online or
connected at the same time as the other you are communicating with for
example as with voice mail, email or written letters.
In the online world email, lists, conferences and newsgroups are examples of
such a method of communication.
"
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"" <a@b.com> schrieb: | Mhm... In this particular case I prefer: | | \\\ | Dim k, m, n As Integer | ... | If m > n Then | k = m | Else | k = n | End If | ///
i prefer not listing variables on a single line as it is hard to read and maintain.
Yeah, I only wanted to demonstrate that all variables are of type 'Integer'.
but as for the code:
k = math.max(m,n)
In this particular situation this is the preferrable solution. However,
it's not a general replacement for 'IIf'.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:ej**************@TK2MSFTNGP11.phx.gbl...
| "" <a@b.com> schrieb:
| > | Mhm... In this particular case I prefer:
| > |
| > | \\\
| > | Dim k, m, n As Integer
| > | ...
| > | If m > n Then
| > | k = m
| > | Else
| > | k = n
| > | End If
| > | ///
| >
| > i prefer not listing variables on a single line as it is hard to read
and
| > maintain.
|
| Yeah, I only wanted to demonstrate that all variables are of type
'Integer'.
vb.classic people would assume k and m were variants. the best way to
"demonstrate" the type of a variable is to declare each on its own line...no
if's and's or but's about it.
| > k = math.max(m,n)
|
| However,
| it's not a general replacement for 'IIf'.
i never said it was...i offered it as a specific relief to the problem the
op was having as it looked more fitting a solution to his delima. and, IIF
is not a general replacement for condition ? true : false; syntax
either...consider:
avg = total ? item/total : 0;
if total were 0 in the above, it would not error because it would not be
evaluated...if, however, you did the same thing with an iif:
avg = iif(total, item/total, 0)
you would get an error before the condition was ever evaluated - when total
eq. 0. iif is a very flimsy construct which should have already been
addressed in vb.net. and on a similar note...why not fully support
in/decrementors (++ --)...i mean the best they can do in vb.net is variable
+= value ... come on! but, i digress.
"" <a@b.com> schrieb: and, IIF is not a general replacement for condition ? true : false; syntax either...consider:
Nobody here ever claimed that...
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OA**************@TK2MSFTNGP11.phx.gbl...
| From <URL:http://internet.ggu.edu/university_library/conf.html>:
|
| "
| Asynchronous Methods of communication do not require you to be online or
| connected at the same time as the other you are communicating with for
| example as with voice mail, email or written letters.
|
| In the online world email, lists, conferences and newsgroups are examples
of
| such a method of communication.
| "
from
<url:http://www.stats.gla.ac.uk/steps/glossary/hypothesis_testing.html#sl>
"The significance level of a statistical hypothesis test is a fixed
probability of wrongly rejecting the null hypothesis H0, if it is in fact
true."
meaning, your excuse for this occurrence is mute or more likely to be null
based on 3+ years of consistently agreeing sample data. it simply seems more
a matter of course than anomaly.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uP****************@TK2MSFTNGP10.phx.gbl...
| > and, IIF is not a general replacement for condition ? true : false;
syntax
| > either...consider:
|
| Nobody here ever claimed that...
shit man! you can't read...or are you asynchronous communications lagging
again? LOL...this should help refresh your memory:
| : is there a way to do something like this
| : k = (i > j) ? i : j
| :
| : Thanks,
| : Rich
|
|
| k = Iif(i > j, i, j)
|
|
| Ralf
Aww, here you go ...
" is the smartest programmer in the universe."
Bookmark and revisit as often as needed to maintain stability
(get well soon)
"Workgroups" <no*****@domainless.com> wrote in message
news:Ou*****************************************@s peakeasy.net...
| Aww, here you go ...
|
| " is the smartest programmer in the universe."
|
| Bookmark and revisit as often as needed to maintain stability
| (get well soon)
see...now that's funny!
;^)
Rich,
As _AnonCoward & the other suggests you can use IIf.
The "problem", as you found out, with IIf is its a function that accepts
Object & Returns Object.
If you are using VS 2005 (aka Whidbey, due out later in November 2005) I
would suggest using a Generic IIf, such as: http://www.tsbradley.net/Cookbook/Ge...enericIIf.aspx
Hope this helps
Jay
"Rich" <Ri**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
| Dim i, j, k As Integer
| i = 2 : j = 3
|
| If i > j Then
| k = i
| Else
| k = j
| End If
|
| is there a way to do something like this
| k = (i > j) ? i : j
|
| Thanks,
| Rich
|
Herfried,
| VB 2005 will suppport a
| generic version of 'IIf' which will work strongly-typed, which removes the
| need of casting.
Is a Generic IIf going to be part of the Microsoft.VisualBasic, or will we
have to use my Generic IIf?
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e%******************@TK2MSFTNGP14.phx.gbl...
| "Rich" <Ri**@discussions.microsoft.com> schrieb:
| > Dim i, j, k As Integer
| > i = 2 : j = 3
| >
| > If i > j Then
| > k = i
| > Else
| > k = j
| > End If
| >
| > is there a way to do something like this
| > k = (i > j) ? i : j
|
| 'IIf'. However, note that 'IIf' is a function and thus both parts (true
| part and false part) will get evaluated. In addition to that, casting
will
| be required if 'Option Strict' is turned on. VB 2005 will suppport a
| generic version of 'IIf' which will work strongly-typed, which removes the
| need of casting.
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
Herfried,
The Generic IIf doesn't appear in Beta 2 of VS 2005, which is the version
I'm currently running, hence I didn't realize we were getting it.
However I see its listed on the VS 2005 web site: http://msdn2.microsoft.com/library/m...us,vs.80).aspx
An update to my web site will be in later today...
Thanks
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e%******************@TK2MSFTNGP14.phx.gbl...
| "Rich" <Ri**@discussions.microsoft.com> schrieb:
| > Dim i, j, k As Integer
| > i = 2 : j = 3
| >
| > If i > j Then
| > k = i
| > Else
| > k = j
| > End If
| >
| > is there a way to do something like this
| > k = (i > j) ? i : j
|
| 'IIf'. However, note that 'IIf' is a function and thus both parts (true
| part and false part) will get evaluated. In addition to that, casting
will
| be required if 'Option Strict' is turned on. VB 2005 will suppport a
| generic version of 'IIf' which will work strongly-typed, which removes the
| need of casting.
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
Jay,
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb: The Generic IIf doesn't appear in Beta 2 of VS 2005, which is the version I'm currently running, hence I didn't realize we were getting it.
However I see its listed on the VS 2005 web site:
http://msdn2.microsoft.com/library/m...us,vs.80).aspx
When posting I realized the same as you posted, which is that the generic
'IIf' is missing in "Microsoft.VisualBasic.dll" although documentation lists
it. Thus I assumed (hoped!) that it will be added in near future.
An update to my web site will be in later today...
Mhm... I didn't know that you have a website. Is it public?
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
Your eye was on the same
:-)
However as well I was looking to the IIF (CTP aug), it is there. However it
is better that I stop for today as you saw in that other message, I will
message the result of that tomorrow.
:-)
Cor
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb: Your eye was on the same
:-)
However as well I was looking to the IIF (CTP aug), it is there.
Mhm... I don't see the generic version of 'IIf' in the August CTP. It
seems that the function has been removed from the documentation too :-(((.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
I see it listed at: http://msdn2.microsoft.com/library/m...us,vs.80).aspx
However I don't have any of the CTP's loaded so I don't know if its in the
local copy or the "Microsoft.VisualBasic.dll" assembly yet.
| > An update to my web site will be in later today...
| Mhm... I didn't know that you have a website. Is it public?
I just started it last week, so its a little barren right now: http://www.tsbradley.net/Cookbook/Ge...enericIIf.aspx
I'm working on top level navigation today & my Recommended Reading section.
Not sure if I will have any updates posted today or not...
Thanks
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
| Jay,
|
| "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb:
| > The Generic IIf doesn't appear in Beta 2 of VS 2005, which is the
version
| > I'm currently running, hence I didn't realize we were getting it.
| >
| > However I see its listed on the VS 2005 web site:
| >
| > http://msdn2.microsoft.com/library/m...us,vs.80).aspx
|
| When posting I realized the same as you posted, which is that the generic
| 'IIf' is missing in "Microsoft.VisualBasic.dll" although documentation
lists
| it. Thus I assumed (hoped!) that it will be added in near future.
|
| > An update to my web site will be in later today...
|
| Mhm... I didn't know that you have a website. Is it public?
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
| This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: JK |
last post by:
Hi All,
I am working a form which is tabular layout (continuous form) which
will display multiple records at a time. Each line of record needs to
be reflected on the color code to show their...
|
by: Prakash Wadhwani |
last post by:
Is there any EASY way to highlight a full row in a continuous form so
that as i navigate up & down the table/continuous form using the arrow
keys, the entire line (all fields) get highlighted ?
...
|
by: Richard |
last post by:
Hi,
I have a form that take some time to load due to many comboboxes and at
least 8 subforms.
When I filter or sort the main form I get an error message and then Access
shuts down. They ask if...
|
by: Randy Harris |
last post by:
Strange problem on A2K. A continuous form is getting some sort of strobe
effect on several systems that have been upgraded to Windows XP (never saw
the problem on Win2K). One of the text boxes is...
|
by: David |
last post by:
Hi,
I need a button shown for each record (cont. form) with specific
captions on each.
I have a notes form for each record. When a user presses the button
they can read the notes. I want to...
|
by: allyn44 |
last post by:
HI--what I am trying to do is 2 things:
1. Open a form in either data entry mode or edit mode depending on
what task the user is performing
2. Cancel events tied to fields on the form if I am in...
|
by: bole2cant |
last post by:
The error I get is:
Cannot access a disposed Object named "Form2".
Object name "Form2".
Here is the sequence which gives the error.
Start program. Form1 comes up and has a button to choose...
|
by: Michael R |
last post by:
Searching the net I've found a simple technique to add row numbers and alternate colors (for the even and the uneven row) to a continuous form.
1st step: Create a textbox, send it to background...
|
by: Filips Benoit |
last post by:
Dear All,
Access 2003 adp on SQL_server 2005
A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and
fill with a SP.
Fields: Companyname, Day1, day2, etc.
The value in the...
|
by: keri |
last post by:
I would like to set up conditional formatting on a form.
One of the fields on the form is a date (). If the calldate
field is over 365 days ago I would like all the other fields on the
form line...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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,...
|
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...
|
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: 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...
| |