All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
Go Back  Xtreme Visual Basic Talk > > > All the Pretty Lights..Driving me Nuts!


Reply
 
Thread Tools Display Modes
  #1  
Old 02-28-2004, 11:21 AM
Lexiy Lexiy is offline
Newcomer
 
Join Date: Feb 2004
Location: Miami
Posts: 6
Question All the Pretty Lights..Driving me Nuts!


Making Memory game, 4 lights, 4 sounds, yadda yadda.

Have the lights and sounds working so that if I click a button the light changes and sound goes ding. Have the randomizer picking a light, so far so good.

Problem:

This is what I have:
Code:
Imports System Imports Microsoft.DirectX.AudioVideoPlayback 'THIS NEEDED FOR DX SOUND Imports Microsoft.DirectX 'THIS NEEDED FOR DX SOUND Public Class LexiyForm Inherits System.Windows.Forms.Form 'declare form level variables Private newForm As New About Private mobjPic As PictureBox Private mobjControl As Control Private mintFirst As Integer Private mintFollow As Integer Private mintLevel As Integer Private mintStep As Integer Private mintClick As Integer 'declare form level collections Private mPictureBoxCollection As New Collection Private Sub AboutMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutMenu.Click If newForm.Enabled = False Then newForm.Show() newForm.Enabled = True End If End Sub Private Sub ExitMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitMenu.Click Me.Close() End Sub Private Sub BlueButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles BlueButton.MouseDown Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("Pics\blued.gif") End Sub Private Sub BlueButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles BlueButton.MouseUp BlueButton.Image = System.Drawing.Bitmap.FromFile("Pics\blue.gif") Sound1 = New AudioVideoPlayback.Audio("sounds\1.mp3") Sound1.play() End Sub Private Sub RedButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RedButton.MouseDown Me.RedButton.Image = System.Drawing.Bitmap.FromFile("pics\redd.gif") End Sub Private Sub RedButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RedButton.MouseUp Me.RedButton.Image = System.Drawing.Bitmap.FromFile("pics\red.gif") Sound2 = New AudioVideoPlayback.Audio("sounds\2.mp3") Sound2.play() End Sub Private Sub GreenButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GreenButton.MouseDown Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("pics\greend.gif") End Sub Private Sub GreenButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GreenButton.MouseUp Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("pics\green.gif") Sound3 = New AudioVideoPlayback.Audio("sounds\3.mp3") Sound3.play() End Sub Private Sub YelButton_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles YelButton.MouseDown Me.YelButton.Image = System.Drawing.Bitmap.FromFile("pics\yellowd.gif") End Sub Private Sub YelButton_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles YelButton.MouseUp Me.YelButton.Image = System.Drawing.Bitmap.FromFile("pics\yellow.gif") Sound4 = New AudioVideoPlayback.Audio("sounds\4.mp3") Sound4.play() End Sub Private Sub EasyMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EasyMenu.Click For Each mobjControl In Controls If TypeOf mobjControl Is PictureBox Then mobjPic = mobjControl mobjPic.Visible = False End If Next Timer1.Enabled = False Timer1.Interval = 500 Me.StartButton.Visible = True End Sub Private Sub LexiyForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 'assign buttons to the form-level collection mPictureBoxCollection.Add(Me.RedButton) mPictureBoxCollection.Add(Me.BlueButton) mPictureBoxCollection.Add(Me.GreenButton) mPictureBoxCollection.Add(Me.YelButton) End Sub Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click For Each mobjControl In Controls If TypeOf mobjControl Is PictureBox Then mobjPic = mobjControl mobjPic.Visible = True End If Next Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("pics\blue.gif") Me.RedButton.Image = System.Drawing.Bitmap.FromFile("pics\red.gif") Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("pics\green.gif") Me.YelButton.Image = System.Drawing.Bitmap.FromFile("pics\yellow.gif") Randomize() mintFollow = CInt(Int((4 * Rnd()) + 1)) Randomize() mintStep = CInt(Int((4 * Rnd()) + 1)) Timer1.Enabled = True Timer1.Interval = 500 Me.StartButton.Visible = False mintLevel = 1 End Sub Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick Call PerformClick() End Sub Private Sub PerformClick() Dim sender As Object, e As System.Windows.Forms.MouseEventArgs Select Case True Case mintFollow = 1 Call BlueButton_MouseDown(sender, e) Case mintFollow = 2 Call RedButton_MouseDown(sender, e) Case mintFollow = 4 Call GreenButton_MouseDown(sender, e) Case mintFollow = 3 Call YelButton_MouseDown(sender, e) End Select For Each mobjControl In Controls If TypeOf mobjControl Is PictureBox Then mobjPic = mobjControl mobjPic.Enabled = True End If Next End Sub Private Sub PerformClick2() Dim sender As Object, e As System.Windows.Forms.MouseEventArgs Call BlueButton_MouseUp(sender, e) End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Call PerformClick2() End Sub End Class

The problem I have so far is that I can't get the light that comes on randomly to turn off. I tried putting in a call to the MouseDown subs but that just loops the lights endlessly. I just want it to come on then turn off with the sound, so then it can move on to the next light. I still have lots to go in coding but I can't get any further till I figure this out, it's driving nuts.

Anyways, I just need to know what I am doing wrong or not doing at all. Not asking for the straight out answer, maybe just a point in the right direction please.

I hope I made my self clear, so confused right now I can't think (or post) straight :P

Thanks
Reply With Quote
  #2  
Old 02-28-2004, 12:23 PM
Iceplug's Avatar
IceplugAll the Pretty Lights..Driving me Nuts! Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Instead of calling the mousedown subs, why don't you just change the picture of the lights:
Looks like you can just select one of these four lines and it will turn off a light for you.
Code:
Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("pics\blue.gif") Me.RedButton.Image = System.Drawing.Bitmap.FromFile("pics\red.gif") Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("pics\green.gif") Me.YelButton.Image = System.Drawing.Bitmap.FromFile("pics\yellow.gif")
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 02-28-2004, 06:31 PM
Lexiy Lexiy is offline
Newcomer
 
Join Date: Feb 2004
Location: Miami
Posts: 6
Default

Quote:
Originally Posted by Iceplug
Instead of calling the mousedown subs, why don't you just change the picture of the lights:
Looks like you can just select one of these four lines and it will turn off a light for you.
Code:
Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("pics\blue.gif") Me.RedButton.Image = System.Drawing.Bitmap.FromFile("pics\red.gif") Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("pics\green.gif") Me.YelButton.Image = System.Drawing.Bitmap.FromFile("pics\yellow.gif")



I've tried it that way, my point is that I can't get it to light up once and then turn off. In other words, if I just say me.bluebutton.image = system.drawing.bitmap.fromfile("pics\blue.gif") to turn if "off" then when I run the program that's all I see, I never see it turn on.

Like I have tried this:
Code:
Select Case True Case mintFollow = 1 Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("pics\blued.gif") Case mintFollow = 2 Me.RedButton.Image = System.Drawing.Bitmap.FromFile("Pics\redd.gif") Case mintFollow = 4 Me.YelButton.Image = System.Drawing.Bitmap.FromFile("Pics\yellowd.gif") Case mintFollow = 3 Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("Pics\greend.gif") End Select If mintFollow = 1 Then Me.BlueButton.Image = System.Drawing.Bitmap.FromFile("Pics\blue.gif") Sound1.play() ElseIf mintFollow = 2 Then Me.RedButton.Image = System.Drawing.Bitmap.FromFile("Pics\red.gif") Sound2.play() ElseIf mintFollow = 3 Then Me.GreenButton.Image = System.Drawing.Bitmap.FromFile("Pics\green.gif") Sound3.play() ElseIf mintFollow = 4 Then Me.YelButton.Image = System.Drawing.Bitmap.FromFile("Pics\yellow.gif") Sound4.play() End If
All I see when I run it is the second pic, and if I click on the button that was picked randomly, It won't stay "on" with the mouseDown like the other do, it's the only way I know which one was randomly called.

Sorry if I can't explain myself correctly.

Lexiy
Reply With Quote
  #4  
Old 02-29-2004, 05:28 PM
Iceplug's Avatar
IceplugAll the Pretty Lights..Driving me Nuts! Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Oh... so you are trying to make the button flash in one procedure.
Add:
Application.DoEvents()
'This will make the 'd' light show up.
System.Threading.Thread.Sleep()
'This will make the program delay long enough for you to see the 'd' light.
and afterwards the other light will come on.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 03-01-2004, 10:32 AM
Lexiy Lexiy is offline
Newcomer
 
Join Date: Feb 2004
Location: Miami
Posts: 6
Default

Quote:
Originally Posted by Iceplug
Oh... so you are trying to make the button flash in one procedure.
Add:
Application.DoEvents()
'This will make the 'd' light show up.
System.Threading.Thread.Sleep()
'This will make the program delay long enough for you to see the 'd' light.
and afterwards the other light will come on.



I put the Application.DoEvents() before the Slecte Case True: no problem.

But no matter where I try to put the System,Threading.Thread.Sleep() line I get the blue sqigglies and something about overload. BTW I first went to plase it after the End If.

Thanks for the help so far,

Lexiy
Reply With Quote
  #6  
Old 03-01-2004, 03:07 PM
Iceplug's Avatar
IceplugAll the Pretty Lights..Driving me Nuts! Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

The Application.DoEvents and the System.Threading.Thread.Sleep(###) should go before the If statement, after the End Select.
Substitute a number in for the ###
and there's no comma between System and Threading.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates driving me nuts! Legend General 1 01-15-2004 07:47 PM
Driving me nuts! Simple... calvn84 General 3 07-31-2003 01:20 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts! All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
 
All the Pretty Lights..Driving me Nuts!
All the Pretty Lights..Driving me Nuts!
 
-->