Hi,

i'm a newbie in visual basic. my teacher asked me to create a 3 page questionaire (1 question per page) which has a timer counting down. when the time expires, it dispalys "time is out" and saves the questions in a text file.

please help me.

design your questions and save it in .rtf format. Use rich text box in vb to load that questionnaire. and use timer control to control the time limit.

thank you very much for the reply blokcer! i am new to VB so sorry if i might be a bit slow to understand things. what i actually have are 3 forms(1 questions each) and 1 timer that should time all the three forms.
i am not sure how to do the .rtf thing for VB. And as for the timer , how can i carry over/continue the countdown to the next forms? i have attached a picture of how my interface looks like.
i know i am asking too much, but please do help me.
thanks a lot.

attached picture

You do not need rich text box I think as Ive seen on your form.. I have coded below base on your need..Change it to fit on to your program.

    Public logintime    As Date
    Public timelimit    As Date
    Public timetoout    As Date
    Public timeleft     As Date
    public currtimeof   As Date

    Private Sub StartTest_Click() 'Command button 
    logintime = Now
    timelimit = TimeValue("00:05:00") 'example time limit is 5 seconds. 
    timetoout = (logintime) + (timelimit)
    timetoout.Caption = Format(timetoout, "mm/dd/yyyy hh:mm:ss AM/PM")
    end sub

    'Set Timer Interval to 1000 first in order for the next block of code to run perfectly
    Private Sub Timer1_Timer()
    currtimeof = Format(Now)
    timeleft = CDate(currtimeof) - CDate(timetoout)
    timeleftshow.Caption = Format(timeleft, "hh:mm:ss") 'to display time left

    'This will detect if user has reach time limit
    If Format(timeleftshow.Caption, "hh:mm:ss") = "00:00:00" Then
        Timer1.Enabled = False
        msgbox "Time is up. Thank you!",vbinformation,"Time Up"
    End If
    end sub

    'Thats it!
    'Ive seen you have text box, you can save the value of the textbox in notepad or array!

once the person answering the question has entered his answer in the textbox then hits submit or save, how will the answer be saved in a separate text file?

Use this API function. Put this in Module:

Public Declare Function WritePrivateProfileString Lib "KERNEL32" _
   Alias "WritePrivateProfileStringA" _
  (ByVal lpSectionName As String, _
   ByVal lpKeyName As String, _
   ByVal lpValue As String, _
   ByVal lpFileName As String) As Long
'SAVING PROFILE SETTINGS TO .INI
Public Sub ProfileSaveItem(lpSectionName As String, _
                           lpKeyName As String, _
                           lpValue As String, _
                           lpFileName As String)

Call WritePrivateProfileString(lpSectionName, _
                                  lpKeyName, _
                                  lpValue, _
                                  lpFileName)

End Sub

'Now here is the writing/saving part to notepad as .ini file
Public Sub write_settings_to_ini(ByVal keyname As String, ByVal keyvalue As String)
lpFileName = App.Path & "\Answers.ini" 'file name of the notepad .ini, must be in app folder
Call ProfileSaveItem("Answers", keyname, keyvalue, lpFileName)
End Sub

'Answers.ini must have this profile content
'[Answers]
'textbox1_ans=""

'Do this on the form!
Private Sub_Next()
write_settings_to_ini "textbox1_ans", textbox1.text)
End Sub

thank you again.

can you send me the whole file at code_dude8@yahoo.com

I think the code above will make your program running. I do not have the whole program. Ive just coded base on your problem!

i tried it but it comes up with errors. i'm really sorry, i'm really new with this.

what do you mean by "Use this API function. Put this in Module:"?

i started from scratch because i wanted to finish the part where the value in the textbox gets saved in a text file. (i'll deal with the timer thing later on).

i made a new form (Form1) and a button (Button1). i pasted the codes you gave above and attached is what i got.

Your are posting in a wrong forum. It seems that you are using VB.Net. Please post your questions to VB.Net forum!

sorry for that blocker. anyway i was able to finish my project. thank you for the ideas...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.