Solved

popup windows

Posted on 2002-06-01
5
127 Views
Last Modified: 2010-05-02
I have two forms frmMAin and frmWrong,
frmMain has 2 textboxes named

txtinput1 and txtinput2
a label with "+" in between them.
and a "=" at the end of them
and chackbox named chkanswer

frmWrong has 1 textbox on it  
named txtanswer

now how do I hide the frmMain and display the frmWrong with appropriate answer then hide it and display the main form after a certain length of time?  

Thank you, John
0
Comment
  • 4
5 Comments
 
LVL 18

Expert Comment

by:Crash2100
ID: 7049024
you could just use the msgbox function if frmWrong doesn't have much to display.  Something like this:

Private Sub Command1_Click()
    MsgBox "Incorrect answer." & vbCrLf & "The correct answer is: " & (CDbl(Text1) + CDbl(Text2))
End Sub


0
 
LVL 18

Expert Comment

by:Crash2100
ID: 7049030
'Put this code in frmMain:


Function GetNewTime(Number As Integer, IntervalType As String)
    'Intervals are the same as in the DateAdd function
    'yyyy Year
    'q Quarter
    'm Month
    'y Day of year
    'd Day
    'w Weekday
    'ww Week
    'h Hour
    'n Minute
    's Second
  Dim FirstDateAndTime As Date
  FirstDateAndTime = Date + Time
  GetNewTime = DateAdd(IntervalType, Number, FirstDateAndTime)
End Function

Function WaitTill(NewTime)
  Dim CurrentDateAndTime
  CurrentDateAndTime = Date + Time
  Do While CurrentDateAndTime < NewTime
    DoEvents
    Let CurrentDateAndTime = Date + Time
    DoEvents
  Loop
End Function



Private Sub Command1_Click()
    frmWrong.txtAnswer.Text = CDbl(Text1) + CDbl(Text2)
    frmWrong.Show
    WaitTill (GetNewTime(5, "s"))  'pauses for 5 seconds
    frmWrong.Hide
End Sub

0
 
LVL 18

Accepted Solution

by:
Crash2100 earned 100 total points
ID: 7049045
You could also do the same thing using a timer control:


Private Sub Command1_Click()
    frmWrong.txtAnswer.Text = CDbl(Text1) + CDbl(Text2)
    frmWrong.Show
    Timer1.Interval = 5000
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    Timer1.Enabled = False
    frmWrong.Hide
End Sub
0
 

Author Comment

by:NeedHelpwithVisualBasic
ID: 7049073
Can it be done without the timer control??
0
 
LVL 18

Expert Comment

by:Crash2100
ID: 7049132
Private Sub Command1_Click()
    frmWrong.txtAnswer.Text = CDbl(Text1) + CDbl(Text2)
    frmWrong.Show
   
    Dim NewTime As Date
    NewTime = DateAdd("s", 5, Date + Time)

    Do While NewTime > Date + Time
        DoEvents
    Loop
   
    frmWrong.Hide
End Sub
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now