Solved

popup windows

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month4 days, 21 hours left to enroll

635 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