5 Replies - 602 Views - Last Post: 30 November 2013 - 04:05 PM Rate Topic: -----

#1 safrtich  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-November 13

Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 02:41 PM

I tried locking the textboxes using readonly and enabled false with checkbox checked, but the program still changes the variables within the textbox as the program continues to run, what I want it to do is lock the contents of the textbox until the checkbox is unchecked but there is no locked command in cisual basic 2010

    Private Sub CheckBox10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox10.CheckedChanged
        If CheckBox10.Checked = True Then
            TextBox5.Enabled = False
        End If
    End Sub

    Private Sub CheckBox11_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox11.CheckedChanged
        If CheckBox11.Checked = True Then
            TextBox6.ReadOnly = True
        End If
    End Sub
End Class




secondly when trying to tally the score, even if the die are "held" the random generator is still functioning causing my scoring to display the number that is in the program and not always the one displayed.

is there a way to assign a value to a picture so then I can say by the third roll if picturebox1.image=1 then counter1 +=1? or to temporarily stop the random generator until 3 rolls has occurred?


Public Class Form1

    Private x As Integer
    Private Rand1, Rand2, Rand3, Rand4, Rand5 As Integer
    Private counter1, counter2, counter3, counter4, counter5, counter6 As Integer
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim RandomClass As New Random()
        Randomize()
        Rand1 = RandomClass.Next(1, 7)
        Rand2 = RandomClass.Next(1, 7)
        Rand3 = RandomClass.Next(1, 7)
        Rand4 = RandomClass.Next(1, 7)
        Rand5 = RandomClass.Next(1, 7)

        If x < 3 Then
            If CheckBox1.Checked = True Then
            Else
                Select Case Rand1
                    Case 1
                        PictureBox1.Image = My.Resources._1
                    Case 2
                        PictureBox1.Image = My.Resources._2
                    Case 3
                        PictureBox1.Image = My.Resources._3
                    Case 4
                        PictureBox1.Image = My.Resources._4
                    Case 5
                        PictureBox1.Image = My.Resources._5
                    Case 6
                        PictureBox1.Image = My.Resources._6
                End Select
            End If

            If CheckBox2.Checked = True Then
            Else
                Select Case Rand2
                    Case 1
                        PictureBox2.Image = My.Resources._1
                    Case 2
                        PictureBox2.Image = My.Resources._2
                    Case 3
                        PictureBox2.Image = My.Resources._3
                    Case 4
                        PictureBox2.Image = My.Resources._4
                    Case 5
                        PictureBox2.Image = My.Resources._5
                    Case 6
                        PictureBox2.Image = My.Resources._6
                End Select
            End If

            If CheckBox3.Checked = True Then
            Else
                Select Case Rand3
                    Case 1
                        PictureBox3.Image = My.Resources._1
                    Case 2
                        PictureBox3.Image = My.Resources._2
                    Case 3
                        PictureBox3.Image = My.Resources._3
                    Case 4
                        PictureBox3.Image = My.Resources._4
                    Case 5
                        PictureBox3.Image = My.Resources._5
                    Case 6
                        PictureBox3.Image = My.Resources._6
                End Select
            End If

        If CheckBox4.Checked = True Then
        Else
            Select Case Rand4
                Case 1
                    PictureBox4.Image = My.Resources._1
                Case 2
                    PictureBox4.Image = My.Resources._2
                Case 3
                    PictureBox4.Image = My.Resources._3
                Case 4
                    PictureBox4.Image = My.Resources._4
                Case 5
                    PictureBox4.Image = My.Resources._5
                Case 6
                    PictureBox4.Image = My.Resources._6
            End Select
        End If

        If CheckBox5.Checked = True Then
        Else
            Select Case Rand5
                Case 1
                    PictureBox5.Image = My.Resources._1
                Case 2
                    PictureBox5.Image = My.Resources._2
                Case 3
                    PictureBox5.Image = My.Resources._3
                Case 4
                    PictureBox5.Image = My.Resources._4
                Case 5
                    PictureBox5.Image = My.Resources._5
                Case 6
                    PictureBox5.Image = My.Resources._6
            End Select
        End If
        x += 1
        If x = 3 Then
                MsgBox("End turn, Select Score You Would Like to Keep")
                Select Case Rand1
                    Case 1
                        counter1 += 1
                    Case 2
                        counter2 += 2
                    Case 3
                        counter3 += 3
                    Case 4
                        counter4 += 4
                    Case 5
                        counter5 += 5
                    Case 6
                        counter6 += 6
                End Select
                Select Case Rand2
                    Case 1
                        counter1 += 1
                    Case 2
                        counter2 += 2
                    Case 3
                        counter3 += 3
                    Case 4
                        counter4 += 4
                    Case 5
                        counter5 += 5
                    Case 6
                        counter6 += 6
                End Select
                Select Case Rand3
                    Case 1
                        counter1 += 1
                    Case 2
                        counter2 += 2
                    Case 3
                        counter3 += 3
                    Case 4
                        counter4 += 4
                    Case 5
                        counter5 += 5
                    Case 6
                        counter6 += 6
                End Select
                Select Case Rand4
                    Case 1
                        counter1 += 1
                    Case 2
                        counter2 += 2
                    Case 3
                        counter3 += 3
                    Case 4
                        counter4 += 4
                    Case 5
                        counter5 += 5
                    Case 6
                        counter6 += 6
                End Select
                Select Case Rand5
                    Case 1
                        counter1 += 1
                    Case 2
                        counter2 += 2
                    Case 3
                        counter3 += 3
                    Case 4
                        counter4 += 4
                    Case 5
                        counter5 += 5
                    Case 6
                        counter6 += 6
                End Select
                TextBox1.Text = counter1
                TextBox2.Text = counter2
                TextBox3.Text = counter3
                TextBox4.Text = counter4
                TextBox5.Text = counter5
                TextBox6.Text = counter6

            End If
        Else

            CheckBox1.Checked = False
            CheckBox2.Checked = False
            CheckBox3.Checked = False
            CheckBox4.Checked = False
            CheckBox5.Checked = False
            PictureBox1.Image = Nothing
            PictureBox2.Image = Nothing
            PictureBox3.Image = Nothing
            PictureBox4.Image = Nothing
            PictureBox5.Image = Nothing

            x = 0

        End If
    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Textbox lock problem, and Yahtzee random problem

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3359
  • View blog
  • Posts: 11,373
  • Joined: 12-December 12

Re: Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 02:53 PM

This is VB.NET, not VB6. I've moved it to the VB.NET forum.
Was This Post Helpful? 0
  • +
  • -

#3 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 620
  • View blog
  • Posts: 2,780
  • Joined: 03-December 12

Re: Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 03:09 PM

Enabled and read only are for the user and not the system.


To assign a value to the picture create an array that is based on whatever number is selected corresponds with a picture.
Was This Post Helpful? 0
  • +
  • -

#4 safrtich  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-November 13

Re: Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 03:10 PM

Is there a way to lock it against the system?
Was This Post Helpful? 0
  • +
  • -

#5 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 620
  • View blog
  • Posts: 2,780
  • Joined: 03-December 12

Re: Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 03:25 PM

You could ignore the value and not place it
Was This Post Helpful? 0
  • +
  • -

#6 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 620
  • View blog
  • Posts: 2,780
  • Joined: 03-December 12

Re: Textbox lock problem, and Yahtzee random problem

Posted 30 November 2013 - 04:05 PM

In an if statement (or switch) determine what checkboxes are checked. From there decide what values need to change.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1