Results 1 to 9 of 9

Thread: Help with IIF Condition

  1. #1

    Thread Starter
    Lively Member Nigorr's Avatar
    Join Date
    Apr 2002
    Location
    Brisbane, Australia
    Posts
    106

    Help with IIF Condition

    I want to get a number between 65 and 90 (ascii A-Z) I'm using the following but it aint working.
    VB Code:
    1. For z = 1 To 4
    2.         Randomize
    3.         Num = Round(Rnd * 218 + Rnd * 2, 0)
    4.         blncontinue = True
    5.         While blncontinue = True
    6.           Cool = Num
    7.           If Cool < 65 And Not Cool > 90 Then 'This is where I need help please
    8.             Randomize
    9.             Num = Round(Rnd * 218 + Rnd * 2, 0)
    10.           Else
    11.             blncontinue = False
    12.           End If
    13.         Wend
    14.         randomString = randomString & Chr(Num)
    15.       Next z

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Why not:

    Num = Round(Rnd * (90 - 65)) + 65

    ?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    Lively Member Nigorr's Avatar
    Join Date
    Apr 2002
    Location
    Brisbane, Australia
    Posts
    106
    yes that would work fine, I didn't know how to do it that way, never thought of it. Thank you

  4. #4
    Addicted Member
    Join Date
    Nov 2001
    Location
    Peterborough, UK
    Posts
    160

    Re: Help with IIF Condition

    Originally posted by Nigorr
    [B] If Cool < 65 And Not Cool > 90 Then 'This is where I need help please
    If you look at your logic there, it doesn't quite make sense. Read it out loud

    If cool is LESS THAN 65 AND Cool is NOT GREATER THAN 90 then blah blah blah...

    I would imagine what you originhally wanted was

    VB Code:
    1. if cool >65 and cool <=90 then blah blah blah

    In other words if cool is GREATER than 65 AND cool is LESS THAN OR EQUAL TO 95 then blah blah blah

    Hope this helps with your original logic.


    Pigmy
    Remember - The light at the end of the tunnel could well be an on-coming train !

  5. #5

    Thread Starter
    Lively Member Nigorr's Avatar
    Join Date
    Apr 2002
    Location
    Brisbane, Australia
    Posts
    106
    Pigmy: That is what I originally had but it didn't work.... Kept getting other stuff

  6. #6

    Thread Starter
    Lively Member Nigorr's Avatar
    Join Date
    Apr 2002
    Location
    Brisbane, Australia
    Posts
    106
    no no I see where I went wrong I had what I wanted done in the wrong spot ie, generate the new number should have been in the else bit while exit the loop should have been in the do this bit.

  7. #7
    Addicted Member
    Join Date
    Nov 2001
    Location
    Peterborough, UK
    Posts
    160
    Originally posted by Nigorr
    no no I see where I went wrong I had what I wanted done in the wrong spot ie, generate the new number should have been in the else bit while exit the loop should have been in the do this bit.
    I find that when you have complicated if...then's that sometimes it's worth putting a "breakpont" in the code and when running it seeing where the IDE stops. That way you know the 'flow' that's running in your app.

    Anyway, glad you got it sorted!!!!


    Pigmy
    Remember - The light at the end of the tunnel could well be an on-coming train !

  8. #8
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    IF and IIF (1 I vs 2 I's) are different. in case you didnt know, or maybe it ws a typo.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  9. #9

    Thread Starter
    Lively Member Nigorr's Avatar
    Join Date
    Apr 2002
    Location
    Brisbane, Australia
    Posts
    106
    typo

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