|
-
Feb 12th, 2004, 03:43 PM
#1
Thread Starter
Lively Member
coding prob ***resolved***
i have five values to be compared with a value.
the five values must be greater than some value.
if the 5 values are less than that,
the system will count how many of them are less than
the value.
the count value will be displayed in a label.
my prob is the count value will always return 0 value even though
there is a lesser value .
why is that??
i'm new in vb programming, so anyone here could help me
fixing the coding below.
thank u in advance
VB Code:
bb = 0
If Val(Label98.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label99.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label100.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label102.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label101.Caption) < Val(Labe110.Caption) Then
bb = bb + 1
End If
Label33.Caption = bb
Last edited by azrina; Feb 12th, 2004 at 04:13 PM.
-
Feb 12th, 2004, 03:55 PM
#2
Don't use Else if....just If If if and so on...
-
Feb 12th, 2004, 04:04 PM
#3
Conquistador
NoteMe's correct
If Val(Label101.Caption) < Val(Labe110.Caption) Then bb = bb + 1
-
Feb 12th, 2004, 04:07 PM
#4
-
Feb 12th, 2004, 04:09 PM
#5
Thread Starter
Lively Member
ive tried using 5 individual "if" statements.
another prob is if the count value supposed returns 3 value only
are less than the value, but the system will return 4 values.
why?im confused..
VB Code:
bb = 0
If Val(Label98.Caption) < Val(Label110.Caption) Then
bb = bb + 1
End If
If Val(Label99.Caption) < Val(Label110.Caption) Then
bb = bb + 1
End If
If Val(Label100.Caption) < Val(Label110.Caption) Then
bb = bb + 1
End If
If Val(Label102.Caption) < Val(Label110.Caption) Then
bb = bb + 1
End If
If Val(Label101.Caption) < Val(Labe110.Caption) Then
bb = bb + 1
End If
Label33.Visible = True
Label33.Caption = bb
-
Feb 12th, 2004, 04:09 PM
#6
The bolded part looks like a typo. (You should use Option Explicit if you aren't already)
VB Code:
bb = 0
If Val(Label98.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label99.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label100.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label102.Caption) < Val(Label110.Caption) Then
bb = bb + 1
ElseIf Val(Label101.Caption) < Val([b]Labe110[/b].Caption) Then
bb = bb + 1
End If
Label33.Caption = bb
-
Feb 12th, 2004, 04:12 PM
#7
Thread Starter
Lively Member
i didnt realize that
thank u all for helping
god bless u..
-
Feb 12th, 2004, 04:13 PM
#8
Use Option Explicit...it is better for you... .....then the IDE will tell you when you make mistakes like that...
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
|