|
-
Apr 29th, 2002, 04:39 AM
#1
Thread Starter
Lively Member
and/or statement
Can you clarify what does this statement mean, as I'm getting really confused with the and/or:
if InStr(Label2.Caption, "SSL + SET") And _
InStr(Label2.Caption, "digital cash") Or _
InStr(Label2.Caption, "SSL + SET") Then
Does it mean if either SSL + digital cash is selected then.....?
Thanks.
-
Apr 29th, 2002, 04:46 AM
#2
If the caption contains "SSL + SET" And it also contains "digital cash"
or if the caption contains "SSL + SET" then
do something.
-
Apr 29th, 2002, 04:48 AM
#3
Re: and/or statement
Originally posted by P Lee
Can you clarify what does this statement mean, as I'm getting really confused with the and/or:
if InStr(Label2.Caption, "SSL + SET") And _
InStr(Label2.Caption, "digital cash") Or _
InStr(Label2.Caption, "SSL + SET") Then
Does it mean if either SSL + digital cash is selected then.....?
Thanks.
IF "SSL + SET" And "digital cash" is found, Or "SSL + SET" is found, Then....
-
Apr 29th, 2002, 04:48 AM
#4
-= B u g S l a y e r =-
VB Code:
Private Sub Form_Load()
Label2.Caption = "SSL + SET" & "digital cash"
'the first instr will return 1
'the second instr will return 10
'if u do a And operation on 1 And 10 it will return 0 (false)
If InStr(Label2.Caption, "SSL + SET") And _
InStr(Label2.Caption, "digital cash") Or _
InStr(Label2.Caption, "SSL + SET") Then
MsgBox "sdfasd"
End If
MsgBox 1 And 10
'u should do it like this :
If InStr(Label2.Caption, "SSL + SET") <> 0 And _
InStr(Label2.Caption, "digital cash") <> 0 Then
'.
'.
End Sub
-
Apr 29th, 2002, 04:49 AM
#5
-= B u g S l a y e r =-
I tried to explain, but if this is somewhat unclear, let me know
-
Apr 29th, 2002, 04:50 AM
#6
Thread Starter
Lively Member
thanks, in that case I want both options to be selected so I'll use:
if InStr(Label2.Caption, "SSL + SET") And _
InStr(Label2.Caption, "digital cash") and then
-
Apr 29th, 2002, 04:50 AM
#7
Addicted Member
The AND statement "SSL , SET"
by the And statement must by the SSL and the SET condition or value TRUE
by the Or statement must one value by true the SSL or the SET
that is the different between these two
-
Apr 29th, 2002, 04:50 AM
#8
-= B u g S l a y e r =-
-
Apr 29th, 2002, 04:55 AM
#9
Originally posted by peet
VB Code:
'u should do it like this :
If InStr(Label2.Caption, "SSL + SET") <> 0 And _
InStr(Label2.Caption, "digital cash") <> 0 Then
Good point Peet, I missed that
-
Apr 29th, 2002, 04:59 AM
#10
-
Apr 29th, 2002, 05:00 AM
#11
Thread Starter
Lively Member
sorry guys, but what does the <> actually mean in the suggested recommended code:
If InStr(Label2.Caption, "SSL + SET") <> 0 And _
InStr(Label2.Caption, "digital cash") <> 0 Then
Does it mean if both are selected then........?
If I just done this, then what is the difference?
If InStr(Label2.Caption, "SSL + SET") And _
InStr(Label2.Caption, "digital cash") > 0 Then
-
Apr 29th, 2002, 05:04 AM
#12
-
Apr 29th, 2002, 05:14 AM
#13
It's all about the way you walk...
It doesn't matter.
VB interprets 0 as False and ANYTHING else as TRUE!
1 AND 0 = FALSE
1 OR 0 = TRUE
1 AND 15 = TRUE
0 AND 15 = FALSE
42 OR 0 =TRUE

Does that make sense?
So if:
VB Code:
InStr(Label2.Caption, "SSL + SET")
is greater than 0 then it's TRUE
-
Apr 29th, 2002, 05:25 AM
#14
Bouncy Member
instead of
VB Code:
If InStr(Label2.Caption, "SSL + SET") <> 0 And InStr(Label2.Caption, "digital cash") <> 0 Or _
InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If
i would usually use brackets to make it more readable. i.e.
VB Code:
If [b]([/b]InStr(Label2.Caption, "SSL + SET") <> 0 And InStr(Label2.Caption, "digital cash") <> 0[b])[/b] Or _
InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If
although in the above example you dont need the And bit anyway, it can be left as
VB Code:
If InStr(Label2.Caption, "SSL + SET") <> 0 Or _
InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If
-
Apr 29th, 2002, 05:31 AM
#15
Don't you mean:
VB Code:
If (InStr(Label2.Caption, "digital cash") Or _
InStr(Label2.Caption, "SSL + SET")) Then
MsgBox "sdfasd"
End If
-
Apr 29th, 2002, 05:34 AM
#16
Thread Starter
Lively Member
Thanks guys I understand now.
-
Apr 29th, 2002, 08:05 AM
#17
Bouncy Member
Originally posted by Wokawidget
Don't you mean:
VB Code:
If (InStr(Label2.Caption, "digital cash") Or _
InStr(Label2.Caption, "SSL + SET")) Then
MsgBox "sdfasd"
End If
nope
-
Apr 29th, 2002, 08:08 AM
#18
-= B u g S l a y e r =-
Re: It's all about the way you walk...
Originally posted by Wokawidget
It doesn't matter.
VB interprets 0 as False and ANYTHING else as TRUE!
1 AND 0 = FALSE
1 OR 0 = TRUE
1 AND 15 = TRUE
0 AND 15 = FALSE
42 OR 0 =TRUE

Does that make sense?
So if:
VB Code:
InStr(Label2.Caption, "SSL + SET")
is greater than 0 then it's TRUE
VB Code:
Private Sub Command1_Click()
MsgBox 1 And 12 '( 1 And 1100 = 0
MsgBox 1 And 13 '( 1 and 1101 = 1
MsgBox 1 And 14 '( 1 and 1110 = 0
MsgBox 1 And 15 '( 1 and 1111 = 1
MsgBox 1 And 16 '( 1 and 10001 = 0
End Sub
I assume u agree to this ?
It does matter what u And with what ...
-
Apr 29th, 2002, 08:10 AM
#19
Originally posted by darre1
...although in the above example you dont need the And bit anyway, it can be left as
VB Code:
If InStr(Label2.Caption, "SSL + SET") <> 0 Or _
InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If
errrr...doest this equate to:
VB Code:
If InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If

(a AND b) OR b = a OR b
b OR b = b
(a OR b) AND b = b
(a AND b) AND b = a AND b

Good old kaunaugh maps...spelling is incorrect
-
Apr 29th, 2002, 08:18 AM
#20
Bouncy Member
Originally posted by Wokawidget
errrr...doest this equate to:
VB Code:
If InStr(Label2.Caption, "SSL + SET") <> 0 Then
MsgBox "sdfasd"
End If

oops
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
|