CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: hi lo program

  1. #1
    Join Date
    May 2010
    Posts
    76

    hi lo program

    I have a couple quick questions with the program that I am doing. This program is a hi\lo program and here are my remaining issues...

    1. When I click the high or low button in my program it does not make changes to my token (I want the default tokens to be 100 and added 100 to the text property of my textbox so want to make sure I did that right)

    2. In my program it only shows 13 possibilities but want to have the ability to add more

    3. I also would like to change 1 to ace, 11 to jack, 12 to queen, and 13 to king and would like to get some assistance with that as well

    I think I have everything else taken care of but this is the code I have...

    Code:
    Public Class Form1
    
        Private randomgen As New Random
        Private cards As Integer
        Private cardpicked As Object
        Private clicked As Integer = 1
        Private used1, used2, used3, used4, used5, used6, used7, used8, used9, used10 As Integer
        Private myList As New List(Of Integer)
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            For index As Integer = 1 To 13
    
                myList.Add(index)
    
            Next
    
            ShuffleCards(1000)
    
        End Sub
    
        Private Sub ShuffleCards(ByVal NumberOfTimes As Integer)
    
            Dim listIndex As Integer
            Dim output As String = ""
            Dim currentCard As Integer
    
            Try
    
                For index As Integer = 1 To NumberOfTimes
                    listIndex = randomgen.Next(1, 14) - 1
    
                    'Get a currentCard
                    currentCard = myList.Item(listIndex)
    
                    'Remove it at a RANDOM position.
                    myList.RemoveAt(listIndex)
    
                    'Add it back to the list at the end of the list.
                    myList.Add(currentCard)
    
                Next
    
                For cardNumber As Integer = 1 To 13
                    output &= myList(cardNumber - 1) & ControlChars.NewLine
    
                Next
    
            Catch
    
            End Try
    
            MessageBox.Show("Card Order is now" & ControlChars.NewLine & output)
    
        End Sub
    
        Private Sub PickCard()
    
            Dim cardNumber As Integer
            If myList.Count > 0 Then
    
                cardNumber = myList.Item(0)
                myList.RemoveAt(0)
    
            ElseIf myList.Count = 0 Then
    
                MessageBox.Show("No more cards left sorry!!")
    
                Exit Sub
    
            End If
    
            'BEFORE OPENING THE PROGRAM THIS SHOWS THE ORDER OF THE CARDS
            MessageBox.Show("CardNumber is now " & cardNumber)
    
            clicked = clicked + 1
    
        End Sub
    
    
    
        Private Sub cardCheckButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cardCheckButton.Click
    
            PickCard()
    
        End Sub
    
    
        Private Sub highButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles highButton.Click
            Dim cardNumber As Integer
            If cardNumber > cardpicked Then
                tokensTextBox.Text = tokensTextBox.Text + tokensToBetTextBox.Text
    
            ElseIf cardNumber < cardpicked Then
                tokensTextBox.Text = tokensTextBox.Text - tokensToBetTextBox.Text
    
            End If
    
        End Sub
    
        Private Sub tokensTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tokensTextBox.TextChanged
            'START WITH 100 TOKENS
    
        End Sub
    
        Private Sub lowButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lowButton.Click
            Dim cardNumber As Integer
            If cardNumber > cardpicked Then
                tokensTextBox.Text = tokensTextBox.Text - tokensToBetTextBox.Text
    
            ElseIf cardNumber < cardpicked Then
                tokensTextBox.Text = tokensTextBox.Text + tokensToBetTextBox.Text
    
            End If
        End Sub
    
        Private Sub quitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quitButton.Click
            Me.Close()
        End Sub
    
        Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
            Me.Close()
        End Sub
    
        Private Sub tokensToBetTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tokensToBetTextBox.TextChanged
            If Val(tokensToBetTextBox.Text) < 10 Then
                tokensToBetTextBox.Text = Val(tokensToBetTextBox.Text)
            End If
        End Sub
    End Class

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: hi lo program

    Looks like you chose the wrong forum. This is for VB6, not VB.Net...

    The first problem (which you might not notice) is the DIM statement. Unless you specify, the default is Object.

    Code:
     Private used1, used2, used3, used4, used5, used6, used7, used8, used9, used10 As Integer
    Only the last As Integer. (You would need As Integer repeated for each item)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Dec 2001
    Posts
    6,332

    Re: hi lo program

    [ Moved ]
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: hi lo program

    Also, why are you adding two STRINGS?

    Code:
    tokensTextBox.Text = tokensTextBox.Text + tokensToBetTextBox.Text
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured