Solved

VB statement testing 2 values to 1 result

Posted on 2013-01-04
2
255 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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now