Results 1 to 3 of 3

Thread: Resolved [2005] DIm statement twice

  1. #1

    Thread Starter
    Lively Member int3gral's Avatar
    Join Date
    Jan 2007
    Posts
    88

    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


    Quote 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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member int3gral's Avatar
    Join Date
    Jan 2007
    Posts
    88

    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


    Quote 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
  •  



Click Here to Expand Forum to Full Width