我在本節中得到多個錯誤,試圖找出電腦贏,用戶贏或領帶。任何人都可以請幫助編輯我的代碼?我剛剛結束了我的能力。我猜我必須使用對象?但是我一直在編輯我的代碼,而且從這裏只會變得更糟。如果有人能幫助我,我會非常感謝!VB.net ..使用對象時出錯?
' Card shuffling and dealing application.
Public Class DeckOfCardsTest
Dim userwin As Integer
Dim compwin As Integer
Dim ties As Integer
Private deck As New DeckOfCards() ' create the deck of cards
' shuffle the deck when user clicks the Shuffle Button
Private Sub shuffleButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles shuffleButton.Click
deck.Shuffle() ' shuffles the deck
card1PictureBox.Image = Nothing ' clear image
card2PictureBox.Image = Nothing ' clear image
dealButton.Enabled = True ' allow user to click the Deal Button
MessageBox.Show("Deck is shuffled")
End Sub ' shuffleButton_Click
Private Sub dealButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles dealButton.Click
End Sub ' dealButton_Click
' return an image for the Card argument
Private Function GetCardImage(ByVal card As Card) As Image
If card IsNot Nothing Then
' retrieve specific card image from resources
Dim pictureResource = My.Resources.ResourceManager.GetObject(
card.ToString().Replace(" ", ""))
Return CType(pictureResource, Image) ' return Image
Else
dealButton.Enabled = False ' disable the Deal Button
Return Nothing ' no more cards
End If
End Function ' GetCardImage
End Class ' DeckOfCardsTest
這個功課? – stevehipwell 2013-05-01 12:27:07
您能否更具體地瞭解一個特定的問題,並將代碼修剪到仍然存在問題的最小量。這樣做可能會告訴你原因是什麼。 – 2013-05-01 12:28:37
'cardXPictureBox'派生自PictureBox控件嗎? – ajakblackgoat 2013-05-01 12:28:43