我是VB.NET編程新手,不知道ByRef和ByVal如何在這個Blackjack代碼中工作!謝謝!如何通過使用ByVal和ByRef使此程序更高效?
下面是代碼的一部分:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If hit = 0 Then
getCard()
PictureBox3.Image = cImg(n)
playertotal += value
If playertotal > 21 And pAce >= 1 Then
pAce -= 1
playertotal -= 10
End If
End If
If hit = 1 Then
getCard()
PictureBox4.Image = cImg(n)
playertotal += value
If playertotal > 21 And pAce >= 1 Then
pAce -= 1
playertotal -= 10
End If
End If
If hit = 2 Then
getCard()
PictureBox5.Image = cImg(n)
playertotal += value
If playertotal > 21 And pAce >= 1 Then
pAce -= 1
playertotal -= 10
End If
End If
hit += 1
Label2.Text = playertotal
If Label2.Text > 21 Then
Label11.Text = "COMPUTER WINS!"
End If
If hit = 3 And playertotal <= 21 Then
Label11.Text = "PLAYER WINS!"
End If
End Sub
[BYVAL和爲ByRef參考類型](的可能的複製的http://計算器。 com/questions/19707622/byval-by-byref-with-reference-type) – cokeman19
你爲什麼認爲你應該改變和事件簽名? – Plutonix
是否需要使用byRef或byVal? – ElenaDBA