|
-
Apr 21st, 2009, 02:38 PM
#1
Thread Starter
PowerPoster
-
Apr 21st, 2009, 03:02 PM
#2
Re: 3 label 9 condition?
If each Caption is to be separated by a single space this statement is all you need.
str = Trim$(Trim$(Trim$(Label1.Caption) & " " & Trim$(Label2.Caption)) & " " & Trim$(Label3.Caption))
-
Apr 21st, 2009, 03:16 PM
#3
Re: 3 label 9 condition?
No you have 8 combinations. A label is either empty or not so it only have two states and you have 3 labels which gives 2^3 = 8 combinations.
If you don't care what the text in the labels read but only want to check if the Caption is empty or not you can convert these states into numbers from 0 to 7.
0 = All three labels are blank
1 = Label1 contains text, the others are empty.
2 = Label2 contains text, the others are empty.
3 = Label1 and Label2 contains text while Label3 is empty.
4 = Label3 contains text, the others are empty.
5 = Label3 and Label1 contains text while Label2 is empty.
6 = Label3 and Label2 contains text while Label1 is empty.
7 = All labels contains text.
You can easily get these numbers by saying that Label1 have the value 1 if it contains text, Label2 have the value 2, while Label3 have the value 4 (binary). If a label doesn't contain text it has the value 0.
Code:
Dim value As Integer
value = IIf(Label1.Caption <> "", 1, 0)
value = value + IIf(Label2.Caption <> "", 2, 0)
value = value + IIf(Label3.Caption <> "", 4, 0)
Using the code above "value" will be something between 0 and 7. Now use a Select Case and do whatever.
-
Apr 21st, 2009, 08:40 PM
#4
Re: 3 label 9 condition?
Joacim
Very nicely presented (the cases 0 - 7) 
Spoo
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|