Solved

popup windows

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

749 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