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:
Private Function RndCard() As Integer lop: RndCard = Rnd * 52 If RndCard = 0 Then GoTo lop ElseIf RndCard = D1 Then GoTo lop ElseIf RndCard = D2 Then GoTo lop ElseIf RndCard = D3 Then GoTo lop ElseIf RndCard = D4 Then GoTo lop ElseIf RndCard = D5 Then GoTo lop ElseIf RndCard = P1 Then GoTo lop ElseIf RndCard = P2 Then GoTo lop ElseIf RndCard = P3 Then GoTo lop ElseIf RndCard = P4 Then GoTo lop ElseIf RndCard = P5 Then GoTo lop End If End Function
this works but what i initially tried to do was this
VB Code:
Private Function RndCard() As Integer lop: RndCard = Rnd * 52 If RndCard = 0 Or D1 Or D2 Or D3 Or D4 Or D5 Or P1 Or P2 Or P3 Or P4 Or P5 Then GoTo lop End If 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![]()




Reply With Quote