Results 1 to 8 of 8

Thread: Baseball Program

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Baseball Program

    hi

    I am working on a baseball progam and i am stuck on something..wonder if anybody can help me

    so basically what i have is when ball = 4..i have a picture box that prints out walk..then on a label box, the color turns yellow

    now..the part where i am stuck is if it throws 4 more balls..how do i make both first base and second base yellow

    thank you
    Last edited by supraznchnk; Apr 29th, 2006 at 10:25 PM.

  2. #2
    Lively Member
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    64

    Re: Baseball Program

    u mean that u want both label for the 1st and 2nd base turn to yellow?
    I'm Still learning!
    satisfied/not satisfied, PLEASE TAKE SOME TIME TO rate me accordingly.
    Ur opinions helps me to be better!


    Appreciation Triggers Another Good Deeds.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Re: Baseball Program

    yea..

    thanks

  4. #4
    Addicted Member
    Join Date
    Apr 2006
    Posts
    155

    Re: Baseball Program

    Using ColorConstants:

    Label1.BackColor = vbYellow
    Label2.BackColor = vbYellow

    Using RGB:

    Label1.BackColor = RGB(255, 255, 0)
    Label2.BackColor = RGB(255, 255, 0)

    Using QBColor:

    Label1.BackColor = QBColor(14)
    Label2.BackColor = QBColor(14)

    Using OLE_COLOR:

    Dim CLR As OLE_COLOR
    CLR = 65000
    Label1.BackColor = CLR
    Label2.BackColor = CLR

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Re: Baseball Program

    Quote Originally Posted by XRsTX
    Using ColorConstants:

    Label1.BackColor = vbYellow
    Label2.BackColor = vbYellow

    Using RGB:

    Label1.BackColor = RGB(255, 255, 0)
    Label2.BackColor = RGB(255, 255, 0)

    Using QBColor:

    Label1.BackColor = QBColor(14)
    Label2.BackColor = QBColor(14)

    Using OLE_COLOR:

    Dim CLR As OLE_COLOR
    CLR = 65000
    Label1.BackColor = CLR
    Label2.BackColor = CLR
    sry i dont get this thanks anway

    what i am actually doing is trying to great a game stimulator..if someone gets on base..it turns yellow..then if someone else gets one it turns yellow.my code so far only does ball, strike, out..it doenst deal with hit or single yet..i kno the score variable there is useless for now

    here is what my codes look like so far
    HTML Code:
    Dim Inning As Integer
    Dim Out As Integer
    Dim Ball As Integer
    Dim Strike As Integer
    Dim Score As Integer
    Private Sub cmdCurve_Click()
        Call Pitch
    End Sub
    Private Sub cmdFastBall_Click()
        Call Pitch
    End Sub
    Private Sub StrikeOutProcedure()
        picResult.Print "Strike"
        Strike = Strike + 1
        lblStrike.Caption = Strike
            'When strike = 3, reset ball to 0..strike to 0 and add 1 to Out
            If Strike = 3 Then
                Out = Out + 1
                Strike = 0
                Ball = 0
                lblStrike.Caption = Strike
                lblBall.Caption = Ball
                lblOut.Caption = Out
                picMessage.Cls
                picMessage.ForeColor = vbRed
                picMessage.Print "Strike 3 !! Your Out!!"
            End If
    End Sub
    Private Function BallProcedure()
        picResult.Print "Ball"
        Ball = Ball + 1
        lblBall.Caption = Ball
            'When ball = 4, set Ball back to 0, Strike back to 0, and put a runner on first
            If Ball = 4 Then
                Ball = 0
                Strike = 0
                lblBall.Caption = Ball
                lblStrike.Caption = Strike
                lblFirstBase.BackColor = vbYellow
                picMessage.Cls
                picMessage.ForeColor = vbBlue
                picMessage.Print "Walk"
            End If
    End Function
    Private Sub InningNew() 'Resets Ball, Strike, Out to zero,clears the bases and turn them white and add 1 to inning
        lblFirstBase.BackColor = vbWhite
        lblSecondBase.BackColor = vbWhite
        lblThirdBase.BackColor = vbWhite
        Ball = 0
        lblBall.Caption = Ball
        Out = 0
        lblOut.Caption = Out
        Strike = 0
        Inning = Inning + 1
        lblInning.Caption = Inning
    End Sub
    Private Sub InningUpdate() 'When Out =3 then it calls Innning New
        If Out = 3 Then
            Call InningNew
        End If
    End Sub
    Private Sub Form_Load() ' When Programs starts,everything is set to 0 and inning is display as 1
        Ball = 0
        lblBall.Caption = Ball
        Out = 0
        lblOut.Caption = Out
        Strike = 0
        lblStrike.Caption = Strike
        Score = 0
        lblScore.Caption = Score
        Inning = 1
        lblInning.Caption = Inning
    End Sub
    Private Sub Pitch()
        Randomize
        Dim x
        x = Rnd
        y = Int(4 * Rnd) + 1
        picResult.Cls
        picMessage.Cls
        
        If y = 1 Then
            Call StrikeOutProcedure
        ElseIf y = 2 Then
            Call StrikeOutProcedure
        ElseIf y = 3 Then
            BallProcedure
        ElseIf y = 4 Then
            BallProcedure
        End If
        
        Call InningUpdate
    End Sub
    thanks

  6. #6
    Addicted Member
    Join Date
    Apr 2006
    Posts
    155

    Re: Baseball Program

    You want to change the Label to Yellow, yes?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Apr 2006
    Posts
    17

    Re: Baseball Program

    Quote Originally Posted by XRsTX
    You want to change the Label to Yellow, yes?
    yes...... only if ball counts reach 4 for the second time in a row..

    thanks

  8. #8
    Lively Member
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    64

    Re: Baseball Program

    here is an idea:

    VB Code:
    1. Public ball As Integer
    2. Public base As Integer
    3. ________________________________________________________________
    4. Private Sub Command1_Click()
    5.  
    6.  
    7.  
    8. ball = ball + 1
    9.  
    10. If ball = 4 Then
    11.  
    12. base = base + 1
    13. ball = 0
    14.     If base <> 4 Then
    15.    
    16.         If base = 1 Then
    17.         Label1.BackColor = vbYellow
    18.         End If
    19.    
    20.         If base = 2 Then
    21.         Label2.BackColor = vbYellow
    22.         End If
    23.        
    24.         If base = 3 Then
    25.         Label3.BackColor = vbYellow
    26.         End If
    27.        
    28.         If base = 4 Then
    29.         Label4.BackColor = vbYellow
    30.         base = 0
    31.         End If
    32.        
    33.    
    34.     End If
    35.    
    36. End If
    37. End Sub
    38. ______________________________________________________________
    39. Private Sub Form_Load()
    40. ball = ball
    41. base = base
    42. End Sub



    TO RUN THIS CODE, PUT 4 LABELS AND 1 COMMAND BUTTON ON UR FORM.
    MAYBE IT WILL GIVE U IDEAS ON HOW TO PUT IT IN YOUR CODES.

    HOPE THAT WILL HELP!
    I'm Still learning!
    satisfied/not satisfied, PLEASE TAKE SOME TIME TO rate me accordingly.
    Ur opinions helps me to be better!


    Appreciation Triggers Another Good Deeds.

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