Results 1 to 9 of 9

Thread: Plz help me w/ this Slot Machine ...!!!

  1. #1

    Thread Starter
    Junior Member hunter2's Avatar
    Join Date
    Jun 2003
    Posts
    19

    Plz help me w/ this Slot Machine ...!!!

    Hi all, I just finish my little project and it runs fine...but I still want to add some thing more in it..but still don't fingure out the eoor..SO some one plz help..

    this is my project..about slot machine

    I have 3 label:
    lblWheel1
    lblWheel2
    lblWheel3

    1 button:
    btnPlay

    1 textbox
    txtInfo

    and here my code

    module1.vb

    Module Module1
    Public wheel1 As Integer
    Public wheel2 As Integer
    Public wheel3 As Integer
    Public Temp1 As Integer
    Public Temp2 As Integer
    Public Temp3 As Integer



    End Module



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlay.Click
    wheel1 = Int(Rnd() * 3 + 1)
    wheel2 = Int(Rnd() * 3 + 1)
    wheel3 = Int(Rnd() * 3 + 1)
    Temp1 = wheel1 + 164
    Temp2 = wheel2 + 164
    Temp3 = wheel3 + 164
    lblWheel1.Text = Chr(Temp1)
    lblWheel2.Text = Chr(Temp2)
    lblWheel3.Text = Chr(Temp3)


    If Temp1 = Temp2 = Temp3 Then
    MsgBox("congratulation,You r Win")
    Else
    txtInfo.Text = "Sorry, Please try again"

    End If

    End Sub

    I don't know, why when Im win, but the message Box doesn't appear, and I just only see" sorry, please try a gain message" SOme one know how to fix, Plz help me..Thank You

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Just to your knowledge there is a difference between these two conditions :


    VB Code:
    1. ' 1 this should works fine .
    2. If a And b And c  Then
    3.  
    4.  
    5.  
    6. ' 2 this would always gives bad result even if all these variables are equals
    7. If a = b = c  Then

    So try this now :

    VB Code:
    1. If Temp1 And Temp2 And Temp3 Then
    2.             MsgBox("congratulation,You r Win")
    3.         Else
    4.             txtInfo.Text = "Sorry, Please try again"
    5.  
    6.         End If

  3. #3

    Thread Starter
    Junior Member hunter2's Avatar
    Join Date
    Jun 2003
    Posts
    19
    yeah, this one the msgbox will appear, but It still have error that It appear every time I click on the button "Play" even I don't win.lol..So Plz help me to fix it again..

  4. #4
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    How About

    If a = b AndAlso b = c Then
    Do Whatever
    End if

    [Edited] Don't know where I got "AndIf" from "AndAlso", It's late, anyways the above code should work...
    Last edited by Hinder; Jul 2nd, 2003 at 01:13 AM.

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Upload the proj . The code I posted should work well .

  6. #6

    Thread Starter
    Junior Member hunter2's Avatar
    Join Date
    Jun 2003
    Posts
    19
    here it is:
    Attached Files Attached Files

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What Hinder said is exactly right . Use this condition :
    VB Code:
    1. If (Temp1 = Temp2 AndAlso Temp2 = Temp3) Then

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    and more thing I'd like to mention : You don't need "wheel1" and "wheel2" and "wheel1" variables . You can use the values directly (which is faster way ) like this :

    Before
    VB Code:
    1. wheel1 = Int(Rnd() * 3 + 1)
    2. wheel2 = Int(Rnd() * 3 + 1)
    3. wheel3 = Int(Rnd() * 3 + 1)
    4. Temp1 = wheel1 + 164
    5. Temp2 = wheel2 + 164
    6. Temp3 = wheel3 + 164


    After
    VB Code:
    1. Temp1 = Int(Rnd() * 3 + 1) + 164
    2. Temp2 = Int(Rnd() * 3 + 1) + 164
    3. Temp3 = Int(Rnd() * 3 + 1) + 164

  9. #9

    Thread Starter
    Junior Member hunter2's Avatar
    Join Date
    Jun 2003
    Posts
    19
    thanks guys, i work well now...

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