Results 1 to 8 of 8

Thread: Somethin's wrong... [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Resolved Somethin's wrong... [RESOLVED]

    OK. I have something wrong with my program. I have a bit of Agent code in the Activate part of my program. What the agent is supposed to do is speak. He speaks and tehn a number of seconds later, he says the exact same thing again, which tells me that the activate event is being activated. Now that starts a timer and the whole program goes crazy from that point on. Now does anyone have any clue on what is going on? Any help is appreciated as I am desperate. Thanks.
    Last edited by martw; May 17th, 2005 at 08:36 AM. Reason: resolved
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  2. #2
    Hyperactive Member Lil Ms Squirrel's Avatar
    Join Date
    Nov 2004
    Location
    planet squirrel
    Posts
    494

    Re: Somethin's wrong...

    Post your code so we can see what's happening
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
    Dr. Seuss

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Somethin's wrong...

    VB Code:
    1. Private Sub frmScience2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         lblClose.ImageIndex = 3
    3.         lblMinimize.ImageIndex = 0
    4.     End Sub
    5.  
    6.     Private Sub frmScience2_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
    7.         ' Starts the timer and animates Merlin.
    8.         With Agent
    9.             .Play("Wave")
    10.             .Speak(UserName & ", now you will have to listen and spell the key word.")
    11.         End With
    12.         tmrToGo.Enabled = True
    13.         tmrToGo.Start()
    14.     End Sub
    15.  
    16.     Private Sub tmrToGo_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrToGo.Tick
    17.         Static Counter As Integer = 0
    18.         If Counter = 0 Then
    19.             Counter = Counter + 1
    20.         ElseIf Counter = 1 Then
    21.             lblToGo.Text = "READY..."
    22.             Counter = Counter + 1
    23.         ElseIf Counter = 2 Then
    24.             lblToGo.Text = "...SET..."
    25.             Counter = Counter + 1
    26.         ElseIf Counter = 3 Then
    27.             lblToGo.Text = "...GO!"
    28.             Counter = Counter + 1
    29.         ElseIf Counter = 4 Then
    30.             lblToGo.Text = "LISTEN AND SPELL"
    31.             ' Enable the first question
    32.             grpSound1.Enabled = True
    33.             ' Play the first sound.
    34.             Sound.PlayWavResource("mysterious.wav")
    35.             ' stop the timer so it does not repeat itself.
    36.             tmrToGo.Stop()
    37.             tmrToGo.Enabled = False
    38.             tmrToGo.Dispose()
    39.         End If
    40.     End Sub
    41.     '---------------------------------------------------------------------
    42.     Public Sub AgentMessage()
    43.         ' Shows user-friendly message which says that they may only play
    44.         ' the sound once extra.
    45.         With Agent
    46.             .Play("Decline")
    47.             .Play("Explain")
    48.             .Speak("I will only let you repeat the sound once " & UserName & ".")
    49.             .Play("Pleased")
    50.         End With
    51.     End Sub
    52.  
    53.     Private Sub btnPlaySound1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound1.Click
    54.         Sound.PlayWavResource("mysterious.wav")
    55.         ' the user is only allowed to listen to the sound twice.
    56.         btnPlaySound1.Enabled = False
    57.         AgentMessage()  'Calls subroutine AgentMessage
    58.     End Sub
    59.     Private Sub btnPlaySound2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound2.Click
    60.         Sound.PlayWavResource("consistant.wav")
    61.         btnPlaySound2.Enabled = False
    62.         AgentMessage()
    63.     End Sub
    64.     Private Sub btnPlaySound3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound3.Click
    65.         Sound.PlayWavResource("fracture.wav")
    66.         btnPlaySound3.Enabled = False
    67.         AgentMessage()
    68.     End Sub
    69.     Private Sub btnPlaySound4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound4.Click
    70.         Sound.PlayWavResource("personality.wav")
    71.         btnPlaySound4.Enabled = False
    72.         AgentMessage()
    73.     End Sub
    74.     Private Sub btnPlaySound5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlaySound5.Click
    75.         Sound.PlayWavResource("inadequate.wav")
    76.         btnPlaySound5.Enabled = False
    77.         AgentMessage()
    78.     End Sub
    79.  
    80.     Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
    81.         Quit()
    82.     End Sub
    83.     Private Sub btnMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMain.Click
    84.         With Agent
    85.             .Speak("Lets go find another topic, shall we, " & UserName & "?")
    86.             .Play("DoMagic1")
    87.         End With
    88.         ' Get rid of any stored scores if the user went from Spelling1 to here
    89.         ' and went to main.
    90.         ClearVarSpelling()
    91.         Threading.Thread.Sleep(8000)
    92.         MainForm.Show()
    93.         Me.Close()
    94.     End Sub
    95.     Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
    96.         ' Checks the answers and add to points
    97.         ValidateAnswers()
    98.         ' Globally denotes that maths has been completed.
    99.         SpellingDone = True
    100.         ' Finishes any queued processes
    101.         Application.DoEvents()
    102.         With Agent
    103.             .Play("DoMagic1")
    104.         End With
    105.         ' the thread sleeps for 2.5 seconds for Merlin
    106.         Threading.Thread.Sleep(2500)
    107.         ' Shows the main form
    108.         MainForm.Show()
    109.         Me.Close()
    110.     End Sub
    111.     '---
    112.     Private Sub btnLockIn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLockIn1.Click
    113.         grpSound1.Enabled = False
    114.         grpSound2.Enabled = True
    115.         Sound.PlayWavResource("consistant.wav")
    116.         ' Compares string to string in uppercase and changes textbox
    117.         ' back colour accordingly. Red = wrong, blue = right.
    118.         If txtKeyWord1.Text.ToUpper.Equals("MYSTERIOUS") Then
    119.             txtKeyWord1.BackColor = Color.FromArgb(192, 192, 255)
    120.         Else : txtKeyWord1.BackColor = Color.FromArgb(255, 192, 192)
    121.         End If
    122.     End Sub
    123.     Private Sub btnLockIn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLockIn2.Click
    124.         grpSound2.Enabled = False
    125.         grpSound3.Enabled = True
    126.         Sound.PlayWavResource("fracture.wav")
    127.         If txtKeyWord2.Text.ToUpper.Equals("CONSISTANT") Then
    128.             txtKeyWord2.BackColor = Color.FromArgb(192, 192, 255)
    129.         Else : txtKeyWord2.BackColor = Color.FromArgb(255, 192, 192)
    130.         End If
    131.     End Sub
    132.     Private Sub btnLockIn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLockIn3.Click
    133.         grpSound3.Enabled = False
    134.         grpSound4.Enabled = True
    135.         Sound.PlayWavResource("personality.wav")
    136.         If txtKeyWord3.Text.ToUpper.Equals("FRACTURE") Then
    137.             txtKeyWord3.BackColor = Color.FromArgb(192, 192, 255)
    138.         Else : txtKeyWord3.BackColor = Color.FromArgb(255, 192, 192)
    139.         End If
    140.     End Sub
    141.     Private Sub btnLockIn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLockIn4.Click
    142.         grpSound4.Enabled = False
    143.         grpSound5.Enabled = True
    144.         Sound.PlayWavResource("inadequate.wav")
    145.         If txtKeyWord4.Text.ToUpper.Equals("PERSONALITY") Then
    146.             txtKeyWord4.BackColor = Color.FromArgb(192, 192, 255)
    147.         Else : txtKeyWord4.BackColor = Color.FromArgb(255, 192, 192)
    148.         End If
    149.     End Sub
    150.     Private Sub btnLockIn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLockIn5.Click
    151.         grpSound5.Enabled = False
    152.         btnNext.Enabled = True
    153.         If txtKeyWord5.Text.ToUpper.Equals("INADEQUATE") Then
    154.             txtKeyWord5.BackColor = Color.FromArgb(192, 192, 255)
    155.         Else : txtKeyWord5.BackColor = Color.FromArgb(255, 192, 192)
    156.         End If
    157.     End Sub

    I know its a lot of code, but a lot of it is repetitive. I can't see where the problem is because some of the major parts are copied from another form which doesn't appear to have a problem. I wonder if I'm blind to something or if you guys have a special sense for spotting things... Thanks fi you can find somehting and Thanks if you can't
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Somethin's wrong...

    I know what's wrong!!! Everytime I lose focus of the form (ie: click on another window) the form activate event gets activated! Tahts the problem! Now I don't know how I can fix it...
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  5. #5
    Hyperactive Member Lil Ms Squirrel's Avatar
    Join Date
    Nov 2004
    Location
    planet squirrel
    Posts
    494

    Re: Somethin's wrong...

    Why are you using the Activated event rather than load?
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
    Dr. Seuss

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Somethin's wrong...

    Activate event does the action when the form has shown and thats the main reason. because on a slow comp it may take a while to load things up and the timer will start early. But this is a school assessment so I am only using it on decent machines, so I geuss I'll make the change. I'll keep you poseted.
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Somethin's wrong...

    I owe it to you LMS!
    I never know what to put in this section...



    So sue me... ... ... I'm just kidding...


    www.fat-pie.com Flash Movies... You gotta see 'em to believe 'em!

  8. #8
    Hyperactive Member Lil Ms Squirrel's Avatar
    Join Date
    Nov 2004
    Location
    planet squirrel
    Posts
    494

    Re: Somethin's wrong...

    Happy to be a sounding board
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
    Dr. Seuss

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