arrays - Making every variable in this code Dynamic Visual Basic 2010 -
Sorry for the long piece of code. In a game I am designing, I started this checkbox.checked code if the statement is currently duplicated by clicking 5 times for each box. In each box game, players are equal to a card within the hand
I want to know what I can do to make it more dynamic. I.e. cardcackbox 1 Check object / method as mentioned above the code is repeated 5 times, because I have 5 existing checkboxes. There is a way when I click on a check box and hit it like CardCheckBox2.checked = true, CardCheckBox2.checked = true, press the play button once I understand how to place an array or check box in either archive To make that part dynamic, I can finally start making the rest of the code dynamic, because I think the process of creating dynamic label code will be similar to the checkbox etc.
I
as dim CardCheckBoxArray () checkbox = {CardCheckBox1, CardCheckBox2, CardCheckBox3, CardCheckBox4, CardCheckBox5} modular levels deployed, Form_Load the process, and also Play_Button process, but I'm always up CardCheckBox (N) code .Checked part I
If CardCheckBoxArray (0) .Checked = True and Player1HandGroup (ending with a nullreference exception number 1) .QuantityInteger & gt; 0 then So I do not know where to go with it. The long piece of code makes the other CardCheckBox statement, except for, to have your entire PlayButton_Click process.
Personal sub PlayButton_Click (ByVal Handles this System.Object, as byVal E. System.EventArgs) PlayButton. Click as integer in the form of integer diamond vaponisdiscard integer, integer = 1 etplayplayer dialog. Showdialog () Click on the code to select 'Code' if the etiquette player Dialograsult = Windows Farm Dilog Result Cancel n = 2 ALP ATKplayer DiLog. Dialog Result = Windows Farm Deliog Result. OK then N = 1 ATK Plierdigiog.dialogeregistral = Windows.form. Dialog Result Ebert then N = 3 ATKplayer Dialog. Dialograsult = Windows.form. Dialog result Resume A = 4 ATKplayer Dialog Dialograsult = Windows.form. Dialog Result If ignored then n = 5 and if the card is playing 1 if the cardcackbox 1. Checked = True and Player 1 Hand Group (No. 1). Quantaitigar & gt; 0 Then 'hitpoints decrease when damage .HitPoints delt Player1HandGroup (n) - = Player1HandGroup (number 1) .DamageInteger HitPoints1.Text = Player1HandGroup (1) .HitPoints.ToString HitPoints2.Text = Player1HandGroup (2) .HitPoints.ToString HitPoints3. Text = Player1HandGroup (3) .HitPoints.ToString HitPoints4.Text = Player1HandGroup (4) .HitPoints.ToString HitPoints5.Text = Player1HandGroup (5) .HitPoints.ToString 'when the player moves show, card volume out of hand to the discard pile goes. PlayerlHandGroup (number 1) .QuantityInteger - = 1 DiscardGroup (number 1) .QuantityInteger + = 1 'skip ads shuffle the deck if the deck is out of cards calls DiscardPile ()' Number Generator reset, weapons until number = Do not discard ( DeckGroup (Rnd.ext (0, DeckGroup.Count)) ID if DeckGroup (number) .QuantityInteger & gt; 0 Deck DeckGroup 'Take New Card (number) .QuantityInteger - = 1 Player1HandGroup (number) .QuantityInteger + = 1 Card1Type = Player1HandGroup (number) .CardType CardCheckBox1.Text = Player1HandGroup (number) .CardNameString Number1 = Number or else Call PlayElse () End if
I Use the code then take on the path of taking the form load event out of the form level. When this forn_load event is inside the subroutine, that module is not the same as the scope of the scope.
If you ......
dim CardCheckBoxArray () Czech box = {CardCheckBox1, CardCheckBox2, CardCheckBox3, CardCheckBox4, CardCheckBox5} Sub Form_Load (do so) ... End Sub Sub Play_Button (such as) ... End Sub etc. etc etc
Comments
Post a Comment