random number between 97 - 122

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    random number between 97 - 122

    How can i get a random number >=97 and <= 122 ??
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    This Should Help You

    Regards
    Veena

    Comment

    • BlackMustard
      New Member
      • Aug 2007
      • 88

      #3
      Originally posted by jamesd0142
      How can i get a random number >=97 and <= 122 ??
      use this function:

      [code=vb]function randomnumber(lo westallowed as integer, highestallowed as integer) as integer
      randomize
      randomnumber = lowestallowed + round(rnd * (highestallowed - lowestallowed))
      end function[/code]

      where you need the number in your code:

      [code=vb]
      dim value as integer
      value = randomnumber(97 ,122)[/code]

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        Originally posted by BlackMustard
        use this function:

        [code=vb]function randomnumber(lo westallowed as integer, highestallowed as integer) as integer
        randomize
        randomnumber = lowestallowed + round(rnd * (highestallowed - lowestallowed))
        end function[/code]

        i get round is not declared in vb 2005 express edition??

        Comment

        • QVeen72
          Recognized Expert Top Contributor
          • Oct 2006
          • 1445

          #5
          Hi,

          Instead of round, use :

          Math.Round()
          Or
          Math.Ceiling()
          Or
          Math.Floor()

          Regards
          Veena

          Comment

          Working...