help with delay

manwinder

New member
Joined
Jun 13, 2011
Messages
3
Programming Experience
1-3
i am making a monopoly game and when the player lands on a chance card and it selects a card that says go to the nearest utility, i have a new forum popping up, the problem is i want the user to click ok and then let b continue with the code on the normal forum, here is the code:

            chancecard = "Advance token to the nearest Railroad and pay owner twice the rental to which he/she is otherwise entitled. If Railroad is unowned, you may buy it from the Bank"
            frmChanceCardsAndCommunityChest.Size = New Size(784, 163)
            frmChanceCardsAndCommunityChest.btnOk.Location = New Point(313, 104)
            frmChanceCardsAndCommunityChest.Show()   'this displays the forum
            frmChanceCardsAndCommunityChest.lblChanceCard.Text = chancecard

' i want the delay right here, it should wait for the user to click ok on the frmchancecarddsandcommunitychest and then continue on with the code

            Dim bought As Integer
            bought = checkowner("Reading Railroad")
            If bought = True Then
                rrcost = NumberOfRailroads("Reading Railroad")
                pay("Reading Railroad", playername, rrcost * 2)
            ElseIf bought = False Then
                MonopolyProperty = "Reading Railroad"
                frmProperties.lblProperty.Text = MonopolyProperty
                playername = "player1"
                frmProperties.lblPlayername.Text = playername
                propertyvalue = 200
                frmProperties.Show()
            End If
 
Last edited by a moderator:
Instead of this:
            frmChanceCardsAndCommunityChest.Show()   'this displays the forum
            frmChanceCardsAndCommunityChest.lblChanceCard.Text = chancecard
you should have this:
            frmChanceCardsAndCommunityChest.lblChanceCard.Text = chancecard
            frmChanceCardsAndCommunityChest.ShowDialog()   'this displays the forum
ShowDialog does exactly what you want, i.e. it doesn't return until the user dismisses the dialogue. There are a couple of points to note:

1. Generally speaking, you should be setting the form's DialogResult property to dismiss it. Whatever value you assign is what gets returned by ShowDialog, allowing the caller to determine what action the user took. Clicking the Close button or calling Close is equivalent to setting DialogResult to Cancel.

2. Closing a form that was displayed with ShowDialog does not dispose it, so it's the responsibility of whoever created it to destroy it. Usually that would be done with a Using block.
 
Back
Top