Easy inequality if/then statement...

Engineer Joe

Well-known Member
Joined
Jun 10, 2005
Messages
549
For some reason, I can't seem to make this junk work...here's what i'm trying to do. I have to input values (A and B). I'd like make an if statement that operates only if the values of BOTH A and B were input (i.e. not skipped over. The input is done in a textbox in a userform. This if/then statement is also excecuted at commandbutton_click() by the way.) I thought that this would work, but it isn't

Code:
If Not (A ="" or B="") then
blah, blah blah

What is the best way to indicate that A is not equal to nothing or "" or has been defined????

thanksesseseseses
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Engineer Joe,

It looks like your statement should work properly.

But I'm assuming that A and B are string variables that are set like this:

A = TextBox1.Text

and that the TextBoxes indeed are initialized with a null string. If initialized with any other string (even a single space, as in " "), you should test for that string. If for example, your textboxes were initialized with "(enter dollar value here)" then the test would become:

If Not (A ="(enter dollar value here)" Or B="(enter dollar value here)") Then

or equivalently

If A <> "(enter dollar value here)" Or B <> "(enter dollar value here)" Then


I hope this helps.

Damon
 
Upvote 0
thanks...you won't believe this...but it's been so long since i've written any vba that i forgot the <> sign.... :unsure:
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top