Results 1 to 22 of 22

Thread: [RESOLVED] Weird crash

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    160

    Resolved [RESOLVED] Weird crash

    Ok i finished making Tic-Tac-Toe yesterday in VB just for the fun of it so today i am making blackjack but ran into a weird problem... i made a function to return an integer between 1 and 52, but also excluding all other cards that have been played. here it is:

    VB Code:
    1. Private Function RndCard() As Integer
    2. lop:
    3.     RndCard = Rnd * 52
    4.     If RndCard = 0 Then
    5.         GoTo lop
    6.     ElseIf RndCard = D1 Then
    7.         GoTo lop
    8.     ElseIf RndCard = D2 Then
    9.         GoTo lop
    10.     ElseIf RndCard = D3 Then
    11.         GoTo lop
    12.     ElseIf RndCard = D4 Then
    13.         GoTo lop
    14.     ElseIf RndCard = D5 Then
    15.         GoTo lop
    16.     ElseIf RndCard = P1 Then
    17.         GoTo lop
    18.     ElseIf RndCard = P2 Then
    19.         GoTo lop
    20.     ElseIf RndCard = P3 Then
    21.         GoTo lop
    22.     ElseIf RndCard = P4 Then
    23.         GoTo lop
    24.     ElseIf RndCard = P5 Then
    25.         GoTo lop
    26.     End If
    27. End Function

    this works but what i initially tried to do was this

    VB Code:
    1. Private Function RndCard() As Integer
    2. lop:
    3.     RndCard = Rnd * 52
    4.     If RndCard = 0 Or D1 Or D2 Or D3 Or D4 Or D5 Or P1 Or P2 Or P3 Or P4 Or P5 Then
    5.         GoTo lop
    6.     End If
    7. End Function

    but forsome reason when i used my test button to display RndCard on a label it crashed every time, after i put an elseif before them all it worked, but i just dont understand why the other way kept crashing me.

    any answers would be much appreciated
    Last edited by Cruncher; Feb 12th, 2009 at 06:34 AM.

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