Solved

VB statement testing 2 values to 1 result

Posted on 2013-01-04
2
259 Views
Last Modified: 2013-01-04
Hello Experts,

Seemingly something that should be easy has been very difficult.
Basically I have two hidden fields on an .aspx page. In the code-behind I am trying to set the text of a label depending on the result of whether both items equal the same value.

When I try this below it doesn't work.

If HiddenField1.Value = 0 OR HiddenField2.Value = 0 Then
Label1.Text= ""
Else
Label1.Text = "Both values equal ZERO"

Open in new window


Is there another way to achieve this simply?

Thanks for considering this.
0
Comment
Question by:Phosphor
2 Comments
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 38745642
Label1.Text = If(HiddenField1.Value = 0 AndAlso HiddenField2.Value = 0, "Both values equal ZERO", "")

Open in new window

0
 
LVL 1

Author Comment

by:Phosphor
ID: 38745695
Thank you. It didn't work at first but then I noticed the true/false were transposed.

Label1.Text = If(HiddenField1.Value = 0 AndAlso HiddenField2.Value = 0, "", "Both values equal ZERO")
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question