Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

popup windows

Posted on 2002-06-01
5
Medium Priority
?
134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses

705 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