Solved

popup windows

Posted on 2002-06-01
5
128 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

896 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

17 Experts available now in Live!

Get 1:1 Help Now