Results 1 to 3 of 3

Thread: The Strangest Thing...

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    The Strangest Thing...

    Look at this code...

    VB Code:
    1. 'This code will put a random floating point between 0 and 1 in
    2.         'the Random property of the member object.
    3.         For i = 0 To Group.Count - 1
    4.             Randomize()
    5.             Dim dbl As Double = ((1 * Rnd()) + 0)
    6.             MsgBox(dbl.ToString)
    7.             Group.Members(i).Random = dbl
    8.             MsgBox(Group.Members(i).Random.ToString)
    9.         Next i
    10.  
    11.         'Sanity Check!!!  Read the values back in a message box!
    12.         Dim strTemp As String = ""
    13.         For i = 0 To Group.Count - 1
    14.             strTemp &= Group.Members(i).Random.ToString & vbCrLf
    15.         Next i
    16.         MsgBox(strTemp)

    Ahem... Am I going insane, or is there something really wrong with this code?

    It seems to me that the values are being put into the object correctly, but when I read it back I get the same floating point back for all of the *different* values...

    for instance,

    i will get something like the following for the two message boxes in the first loop... I know the numbers aren't right, but u'll get the idea...

    .1
    .1
    .2
    .2
    .3
    .3
    .4
    .4

    and in the last message box i get

    .4
    .4
    .4
    .4

    What's going on here???

    Thanks,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This could be the same issue as mentioned in your other post:
    http://www.vbforums.com/showthread.p...hreadid=290793

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026
    Yeah, I determined that afterwards... good 'ol binary reader

    sorry, I should have updated my post

    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

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