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.
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.
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")
'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"
'Ive seen you have text box, you can save the value of the textbox in notepad or array!
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, _
'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)
'Answers.ini must have this profile content
'Do this on the form!
write_settings_to_ini "textbox1_ans", textbox1.text)