|
-
Feb 27th, 2007, 07:01 PM
#1
Thread Starter
Lively Member
Resolved [2005] DIm statement twice
do i really have to declare a variable twice
IF intTemp > 32 or < 95 (because doesn’t state if these temp included too) Then
lblWarning.text = “Normal Temperature”
End if
that is wrong
im assuming the following is corrected because it doesnt say that there is build time errors.
If inttemp < 95 And inttemp > 32 Then
lblwarning.Text = "Normal Temperature"
End If
Last edited by int3gral; Feb 28th, 2007 at 11:37 AM.
H22 Turbo guy from Accordtuner.com
im an unknown quantity <10
 Originally Posted by wossname
You should get one of the new rudePods. You can cram about 500 hours of insults, put-downs and slanders on it.
-
Feb 27th, 2007, 07:13 PM
#2
Re: [2005]
That's not declaring a variable twice. This is a declaration:
Code:
Dim intTemp As Integer
This:
Code:
If inttemp < 95 And inttemp > 32 Then
is simply referring to a variable twice and yes, you do have to do it twice. The operators And, Or, AndAlso and OrElse require two Boolean operands. In this case:
Code:
If inttemp < 95 And inttemp > 32 Then
you have two Boolean operands, i.e. (intTemp < 95) evaluates to a Boolean value and (intTemp > 32) also evaluates to a Boolean value. These two Boolean values are the operated on by the And operator and all is well. In this case:
Code:
IF intTemp > 32 or < 95 Then
(< 95) is not valid expression so you get a syntax error. VB provides no shorthand for what you want to doand nor should it. If it did then it would simply make complex Boolean expressions unreadable. If typing the variable name twice tires you out then lie down for a while.
-
Feb 28th, 2007, 11:36 AM
#3
Thread Starter
Lively Member
Re: [2005]
delete this post. i dont know what was amatter with me at the time, its wasting bandwitdh
H22 Turbo guy from Accordtuner.com
im an unknown quantity <10
 Originally Posted by wossname
You should get one of the new rudePods. You can cram about 500 hours of insults, put-downs and slanders on it.
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
|