Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 109,558 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 1,371 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



msgbox with timer

 
Reply to this topicStart new topic

msgbox with timer

j0hnrAiner
post 29 Jul, 2008 - 08:35 PM
Post #1


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


hi guys.. is it possible to make a msgbox box with timer? the user will need not to press the msgbox in order to execute the next line of the program.. i try this but i got wrong expected output..
CODE

msgbox timer1


help me guys pls.. tnx..
User is offlineProfile CardPM

Go to the top of the page


Martyr2
post 29 Jul, 2008 - 08:50 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,365



Thanked 83 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Well first you have to setup the timer's tick event which in there you call the message box. However, the msgbox is modal meaning that it requires the user to interact with it before it continues to process any other lines of code. So you will have to come up with another way to do what you are looking to do.

But you really have to ask yourself if showing a message box every so many ticks on the timer is even a good idea. You shouldn't hit the user with msgboxes like this. Reserve the messagebox only for showing extremely important information that would the intervention of the user.

If you want to elaborate on what you are attempting to do, perhaps we can help further.

Hope that helps you make the correct design choice. smile.gif
User is online!Profile CardPM

Go to the top of the page

j0hnrAiner
post 29 Jul, 2008 - 09:01 PM
Post #3


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


QUOTE(Martyr2 @ 29 Jul, 2008 - 08:50 PM) *

Well first you have to setup the timer's tick event which in there you call the message box. However, the msgbox is modal meaning that it requires the user to interact with it before it continues to process any other lines of code. So you will have to come up with another way to do what you are looking to do.

But you really have to ask yourself if showing a message box every so many ticks on the timer is even a good idea. You shouldn't hit the user with msgboxes like this. Reserve the messagebox only for showing extremely important information that would the intervention of the user.

If you want to elaborate on what you are attempting to do, perhaps we can help further.

Hope that helps you make the correct design choice. smile.gif


tnx for the reply..

my real problem is this..
i hav this difficulty in refreshing the database..
i hav two option button which will display daily record and monthly record respectivetly.. when i press the option 1 the daily records appear but once i pressed the second button, this where my problem occurs, it did not display the monthly reports, i must terminate first my progrma then re-do what i did.. what shuold i do with this? help me pls.. hope you understood what i meant.. bad english..
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 29 Jul, 2008 - 09:05 PM
Post #4


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,365



Thanked 83 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


Is this straight VB6 or are you implementing this through Excel/Access etc? Are you using crystal reports? Can you show us your code that is giving you the problems?

Thanks. smile.gif
User is online!Profile CardPM

Go to the top of the page

j0hnrAiner
post 29 Jul, 2008 - 10:10 PM
Post #5


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


QUOTE(Martyr2 @ 29 Jul, 2008 - 09:05 PM) *

Is this straight VB6 or are you implementing this through Excel/Access etc? Are you using crystal reports? Can you show us your code that is giving you the problems?

Thanks. smile.gif


heres my code:
CODE

Private Sub Option1_Click()
Dim rs1 As New Recordset

ucon.Execute "Delete * from Tmp"

Set urec = Nothing

urec.Open "select * from courses", ucon, adOpenForwardOnly, adLockOptimistic

With urec

Do While Not .EOF
    If CDate(urec.Fields("datee")) = Date Then
       Set rs1 = Nothing
          rs1.Open "Select * from Tmp", ucon, adOpenDynamic, adLockOptimistic
           rs1.AddNew
           rs1!studnum = urec.Fields("course")
           rs1!numhr = urec.Fields("total")
           rs1!course = urec.Fields("datee")
           rs1.UpdateBatch adAffectCurrent
          
     Else
     End If
         .MoveNext
Loop
        
End With
        
      
        MsgBox ("rEADY FOR pRINTING")
        
        With rs1
            DataReport2.Show
        End With
        
        'With DataEnvironment1.rscourse
        '     If .State = adStateClosed Then .Open
        '        .Requery
        '        .Requery
        '        urec.Requery
        '
        '        DataReport2.Show
        '
        'End With
        
    'With DataReport1.Sections("Section4")
    '    .Controls("label14").Caption = "Daily Report"
    'End With

Option1.Value = False
End Sub

Private Sub Option2_Click()
Dim rs2 As New Recordset

ucon.Execute "Delete * from Tmp"
ucon.Execute "Delete * from Tmp"

Set urec = Nothing

urec.Open "select * from courses", ucon, adOpenForwardOnly, adLockOptimistic

With urec

Do While Not .EOF
    If Format(Month(urec.Fields("datee"))) = Format(Month(Now)) Then
    
    Set rs2 = Nothing
          rs2.Open "Select * from Tmp", ucon, adOpenDynamic, adLockOptimistic
           rs2.AddNew
           rs2!studnum = urec.Fields("course")
           rs2!numhr = urec.Fields("total")
           rs2!course = urec.Fields("datee")
           rs2.UpdateBatch adAffectCurrent
          
     Else
     End If
         .MoveNext
Loop
        
End With
        
        MsgBox ("rEADY FOR pRINTING")
        
        With rs2
            DataReport2.Show
        End With
        
        'With DataEnvironment1.rscourse
        '     If .State = adStateClosed Then .Open
        '        .Requery
        '        .Requery
        '        urec.Requery
        '        DataReport2.Show
                
        'End With
        
    'With DataReport1.Sections("Section4")
    '    .Controls("label14").Caption = "Monthly Report"
    'End With
Option2.Value = False
End Sub



i think, theres nothing wrong with the code, because it saves the data on the database, my only problem is displaying the correct data upon pressing the option button.. tell me pls.., if where i got wrong.. tnx..
User is offlineProfile CardPM

Go to the top of the page

khlee04
post 29 Jul, 2008 - 10:37 PM
Post #6


New D.I.C Head

*
Joined: 29 Jul, 2008
Posts: 2

QUOTE(j0hnrAiner @ 29 Jul, 2008 - 08:35 PM) *

hi guys.. is it possible to make a msgbox box with timer? the user will need not to press the msgbox in order to execute the next line of the program.. i try this but i got wrong expected output..
CODE

msgbox timer1


help me guys pls.. tnx..

please you use Windows Api

Private Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal uType As Long, _
ByVal wLanguageId As Long, _
ByVal dwMilliseconds As Long _
) As Long

Private Const IDYES& = 6&
Private Const IDNO& = 7&
Private Const MB_SETFOREGROUND& = &H10000
Private Const MB_YESNO& = &H4&
Private Const MB_ICONASTERISK& = &H40&
Private Const MB_TIMEDOUT& = &H7D00&

Private Sub Form_Load()
Dim lRet As Long
lRet = MessageBoxTimeout(0&, "your message", _
"Timeout MessageBox Test", MB_SETFOREGROUND Or MB_YESNO Or MB_ICONASTERISK, _
0&, 10000&)

Select Case lRet
Case IDYES:
'// your code
Case IDNO:
'// your code

Case MB_TIMEDOUT:
'// your code

End Select
End Sub

User is offlineProfile CardPM

Go to the top of the page

j0hnrAiner
post 29 Jul, 2008 - 11:02 PM
Post #7


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


QUOTE(khlee04 @ 29 Jul, 2008 - 10:37 PM) *

QUOTE(j0hnrAiner @ 29 Jul, 2008 - 08:35 PM) *

hi guys.. is it possible to make a msgbox box with timer? the user will need not to press the msgbox in order to execute the next line of the program.. i try this but i got wrong expected output..
CODE

msgbox timer1


help me guys pls.. tnx..

please you use Windows Api

Private Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal uType As Long, _
ByVal wLanguageId As Long, _
ByVal dwMilliseconds As Long _
) As Long

Private Const IDYES& = 6&
Private Const IDNO& = 7&
Private Const MB_SETFOREGROUND& = &H10000
Private Const MB_YESNO& = &H4&
Private Const MB_ICONASTERISK& = &H40&
Private Const MB_TIMEDOUT& = &H7D00&

Private Sub Form_Load()
Dim lRet As Long
lRet = MessageBoxTimeout(0&, "your message", _
"Timeout MessageBox Test", MB_SETFOREGROUND Or MB_YESNO Or MB_ICONASTERISK, _
0&, 10000&)

Select Case lRet
Case IDYES:
'// your code
Case IDNO:
'// your code

Case MB_TIMEDOUT:
'// your code

End Select
End Sub


what version do you used? i used vb6..
User is offlineProfile CardPM

Go to the top of the page

khlee04
post 29 Jul, 2008 - 11:43 PM
Post #8


New D.I.C Head

*
Joined: 29 Jul, 2008
Posts: 2

QUOTE(j0hnrAiner @ 29 Jul, 2008 - 11:02 PM) *

QUOTE(khlee04 @ 29 Jul, 2008 - 10:37 PM) *

QUOTE(j0hnrAiner @ 29 Jul, 2008 - 08:35 PM) *

hi guys.. is it possible to make a msgbox box with timer? the user will need not to press the msgbox in order to execute the next line of the program.. i try this but i got wrong expected output..
CODE

msgbox timer1


help me guys pls.. tnx..

please you use Windows Api

Private Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" ( _
ByVal hwnd As Long, _
ByVal lpText As String, _
ByVal lpCaption As String, _
ByVal uType As Long, _
ByVal wLanguageId As Long, _
ByVal dwMilliseconds As Long _
) As Long

Private Const IDYES& = 6&
Private Const IDNO& = 7&
Private Const MB_SETFOREGROUND& = &H10000
Private Const MB_YESNO& = &H4&
Private Const MB_ICONASTERISK& = &H40&
Private Const MB_TIMEDOUT& = &H7D00&

Private Sub Form_Load()
Dim lRet As Long
lRet = MessageBoxTimeout(0&, "your message", _
"Timeout MessageBox Test", MB_SETFOREGROUND Or MB_YESNO Or MB_ICONASTERISK, _
0&, 10000&)

Select Case lRet
Case IDYES:
'// your code
Case IDNO:
'// your code

Case MB_TIMEDOUT:
'// your code

End Select
End Sub


what version do you used? i used vb6..


me too ...i used vb6
User is offlineProfile CardPM

Go to the top of the page

j0hnrAiner
post 30 Jul, 2008 - 06:16 PM
Post #9


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


guys... pls check mycodes where i get wrong.. i got stuck up here in displaying the records in the database.. hope you cuold help me on this.. thanks..
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 31 Jul, 2008 - 10:29 PM
Post #10


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,365



Thanked 83 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


I assume DataReport2 is a form? I see you showing it but no where are you looping through your recordset and adding each record to some kind of control.

Are you completely stumped about this part and don't know where to start? Or are you having some issue with putting the data into a particular control? Be descriptive as to what you want to read and where you want the data to be shown.

Thanks. smile.gif
User is online!Profile CardPM

Go to the top of the page

j0hnrAiner
post 3 Aug, 2008 - 07:22 PM
Post #11


New D.I.C Head

*
Joined: 24 Jul, 2007
Posts: 34


My Contributions


QUOTE(Martyr2 @ 31 Jul, 2008 - 10:29 PM) *

I assume DataReport2 is a form? I see you showing it but no where are you looping through your recordset and adding each record to some kind of control.

Are you completely stumped about this part and don't know where to start? Or are you having some issue with putting the data into a particular control? Be descriptive as to what you want to read and where you want the data to be shown.

Thanks. smile.gif



tnx for the reply.. i figure out already where i got wrong.. i forgot to close recordset everytime i terminate data report.. anyway.. tnx po..
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/7/08 11:16PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month