Results 1 to 24 of 24

Thread: Timer Control

  1. #1

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    Timer Control

    I am using VB6 and I want a flash movie to play while showing a message while my database looks up the userid and password codes. Problem is... the database is too small and my flash doesn't get shown. I want to know how I can delay (like 2 seconds ) so I can show that flash doc before it begins looking up in the database. I need some sort of timer control that is triggered by the clicking of the submit button so the user knows that the information is being verified. Thanks on avance!

  2. #2

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    Talking Sorry

    Please excuse the typing... as I am extemely tired!

  3. #3
    Member
    Join Date
    Mar 2003
    Posts
    34
    Display your flash movie on a seperate thread and explicity force the thread to sleep for 2 seconds after calling the db:

    Code:
    using System;
    using System.Threading;
    
    class ShowFlash {
    
        static void Main() {
            Thread t = new Thread(new ThreadStart(DisplayFlash));
            t.Start();
            RetrieveDBInfo();
            t.Abort();
        }
    
        static void DisplayFlash() {
            Console.WriteLine("Display Flash Movie Here..");
        }
    
        static void RetrieveDBInfo() {
            // Retrieve information from db
            Thread.Sleep(2000);
        }
    }

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Timer Control

    Originally posted by BurnMan2003
    I am using VB6 and I want a flash movie to play while showing a message while my database looks up the userid and password codes. Problem is... the database is too small and my flash doesn't get shown. I want to know how I can delay (like 2 seconds ) so I can show that flash doc before it begins looking up in the database. I need some sort of timer control that is triggered by the clicking of the submit button so the user knows that the information is being verified. Thanks on avance!
    If you want to make use of threading , SimonVega got a good example otherwise , paste a timer control , disable it , and fire it after the user fill in empty spaces .

    timer1.interval = 2000
    timer1.enabled =true

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    the code should go inside a button the user will click !

  6. #6
    Member
    Join Date
    Mar 2003
    Posts
    34
    the code should go inside a button the user will click !
    Thanks for the clarification...

  7. #7

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    OK

    Will this work in VB6, because it looks like c++ coding with the braces!

  8. #8

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    Flash

    OK when the user fills in the userid and the password, they click on the submit. I then want the flash movie that says "Validating" to appear and run.. but the database is too small for it to play because it finds the data too fast. How can I from The submit button in VB6 get that flash movie to play for 2 or 3 seconds and then search the database? Thaks, I hope ths is clearerr.... here is the code I have so far under the command button:

    Private Sub cmdSubmit_Click()
    ' Validate Inputs
    On Error GoTo Err_Check
    Dim strsql As String

    strsql = "Select * FROM tblUsers Where UserName = '" & txtUserName.Text & "'"
    flaVerify.Visible = True
    cmdSubmit.Enabled = False


    Set rst = New ADODB.Recordset

    rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
    If Not rst.EOF And Not rst.BOF Then
    If rst!Password = txtPwd.Text Then
    frmSwitch.Show
    Me.Hide


    Else
    flaVerify.Visible = False
    MsgBox "Invalid Password"
    cmdSubmit.Enabled = True

    End If
    Else
    flaVerify.Visible = False
    MsgBox "Invalid User Name"
    cmdSubmit.Enabled = True
    End If
    rst.Close
    Exit_Check:
    Set rst = Nothing
    Exit Sub
    Err_Check:
    MsgBox Err.Description, "Login Function"
    Resume Exit_Check


    End Sub

  9. #9
    Member
    Join Date
    Mar 2003
    Posts
    34
    Just noticed you mentioned VB6...This is a .NET Forum.

    The code I posted is in C#. Here is a VB.NET equivalent:

    Code:
    Imports System
    Imports System.Threading
    
    Public Module Module1
        Sub Main()
            Dim t As New Thread(AddressOf ShowFlash.DisplayFlash)
            t.Start()
            ShowFlash.CallDB()
            t.Abort()
        End Sub
    End Module
    
    Public Class ShowFlash
        Public Shared Sub DisplayFlash()
            Console.WriteLine("Display Flash...")
        End Sub
    
        Public Shared Sub CallDB()
            Console.WriteLine("Call DB")
            Thread.Sleep(2000)
        End Sub
    End Class

  10. #10

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    Thanks

    Will this work in VB6?

  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Thanks

    Originally posted by BurnMan2003
    Will this work in VB6?
    What ! VB6 ???

  12. #12

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    Yes

    yes... VB6, I have to finish this by semester's end, and I don't have time to learn another language and the ne wstuff in .NET. Can you please help! Thanks man!

  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Thanks

    Originally posted by BurnMan2003
    Will this work in VB6?
    It won't work .
    Just try what I've posted , it should work !

  14. #14

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99

    OK

    Using my coding from the command button, where should I insert your code for best results?

  15. #15
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Hold on

  16. #16

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99
    k... Thanks!

  17. #17
    Member
    Join Date
    Mar 2003
    Posts
    34
    Try using the Shell() VB function, passing in the path to your wav file. This will run on a seperate thread.

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Flash

    try this now : add timer1 to your form !
    VB Code:
    1. Private Sub cmdSubmit_Click()
    2. ' Validate Inputs
    3.     On Error GoTo Err_Check
    4.     Dim strsql As String
    5.     strsql = "Select * FROM tblUsers Where UserName = '" & txtUserName.Text & "'"
    6.    
    7.     'Show flash movie
    8. FireTimer
    9.    
    10.     Set rst = New ADODB.Recordset
    11.    
    12.     rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
    13.     If Not rst.EOF And Not rst.BOF Then
    14.         If rst!Password = txtPwd.Text Then
    15.            'Stop the timer
    16.         Timer1.Enabled = False
    17.        
    18.             frmSwitch.Show
    19.             Me.Hide
    20.            
    21.         Else
    22.             flaVerify.Visible = False
    23.            
    24.             'Stop the timer
    25.             Timer1.Enabled = False
    26.            
    27.             MsgBox "Invalid Password"
    28.             cmdSubmit.Enabled = True
    29.            
    30.         End If
    31.     Else
    32.        'Stop the timer
    33.        Timer1.Enabled = False
    34.        
    35.         flaVerify.Visible = False
    36.         MsgBox "Invalid User Name"
    37.         cmdSubmit.Enabled = True
    38.     End If
    39.     rst.Close
    40. Exit_Check:
    41.     Set rst = Nothing
    42.     Exit Sub
    43. Err_Check:
    44.   MsgBox Err.Description, "Login Function"
    45.     Resume Exit_Check
    46. End Sub
    47.  
    48. Sub FireTimer()
    49. Timer1.Enabled = True
    50.     flaVerify.Visible = True
    51.     cmdSubmit.Enabled = False
    52. End Sub
    53. Private Sub Form_Load()
    54. Timer1.Interval = 3000
    55. Timer1.Enabled = False
    56. End Sub

  19. #19

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99
    Will try it.. thanks!

  20. #20

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99
    Gonna have to check it out, because it is still bypassing showing the flash movie when I click the button. It shoudl always show the flash before jumping pages, and it isn't... why????

  21. #21
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Is flaVerify form or flash object ?? Does the form overrides the movie ??

  22. #22

    Thread Starter
    Lively Member BurnMan2003's Avatar
    Join Date
    Feb 2003
    Posts
    99
    flaVerify is the flash movie.... not sure what you mean my overrides movie. It should be shown for 2 seconds before the database is even accessed to search.. just for show you know!

  23. #23
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    try this site which has a good splash screens . It's easy but you missed something out there . I gotta go now

  24. #24
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Re: Flash

    I added StopTimer sub . see if it helps !
    Originally posted by Pirate
    try this now : add timer1 to your form !
    VB Code:
    1. Private Sub cmdSubmit_Click()
    2. ' Validate Inputs
    3.     On Error GoTo Err_Check
    4.     Dim strsql As String
    5.     strsql = "Select * FROM tblUsers Where UserName = '" & txtUserName.Text & "'"
    6.    
    7.     'Show flash movie
    8. FireTimer
    9.    
    10.     Set rst = New ADODB.Recordset
    11.    
    12.     rst.Open strsql, cnn, adOpenForwardOnly, adLockReadOnly
    13.     If Not rst.EOF And Not rst.BOF Then
    14.         If rst!Password = txtPwd.Text Then
    15.            'Stop the timer
    16. StopTimer
    17.        
    18.             frmSwitch.Show
    19.             Me.Hide
    20.            
    21.         Else
    22.             flaVerify.Visible = False
    23.            
    24.             'Stop the timer
    25. StopTimer
    26.            
    27.             MsgBox "Invalid Password"
    28.             cmdSubmit.Enabled = True
    29.            
    30.         End If
    31.     Else
    32.        'Stop the timer
    33. StopTimer
    34.        
    35.         flaVerify.Visible = False
    36.         MsgBox "Invalid User Name"
    37.         cmdSubmit.Enabled = True
    38.     End If
    39.     rst.Close
    40. Exit_Check:
    41.     Set rst = Nothing
    42.     Exit Sub
    43. Err_Check:
    44.   MsgBox Err.Description, "Login Function"
    45.     Resume Exit_Check
    46. End Sub
    47.  
    48. Sub FireTimer()
    49. Timer1.Enabled = True
    50.     flaVerify.Visible = True
    51.     cmdSubmit.Enabled = False
    52. End Sub
    53.  
    54. Sub StopTimer()
    55. Timer1.Enabled = False
    56. flaVerify.Visible = False
    57. cmdSubmit.Enabled = True
    58. End Sub
    59.  
    60. Private Sub Form_Load()
    61. Timer1.Interval = 3000
    62. Timer1.Enabled = False
    63. End Sub

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