Anybody good in vb.net 2008 ??

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
i have made this online quiz system in vb.net in which all the questions and answer are connected to a 2003 access file....when a user selects a subject and gives the answer of the questioin to that subject....the question shold remain only for 30 secs.....after 30 secs another question sholud pop-up in the form
I have done most of the part but when my question changes after 30 secs.....but the timer is still at 0 .... it doesn't restart.....i tried many different methods but couldn't do it.....

thanks for the help in advance
 

Kushan

Active member
Veteran
Joined
Jun 13, 2008
Messages
2,322
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Hi there, would you be able to post some of the sample code; that you've unsuccesfully implemented??

I maybe able to help you atleast put you in the right direction
 

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
well....like i said before i used different methods....but this is the code in my timer_tick that changes the question when tme time is up.....

dim t as integer=30

If (t > 0) Then
Label8.Text = t & " secs left"
t = t - 1
Else

Timer1.Enabled = False
MsgBox("Time up")
inc = inc + 1
NavigateRecords()

End If

NavigateRecords() ..... its a function that shows next question in the access file
 

gamahiro

Active member
Supreme
Joined
Jul 8, 2010
Messages
32,579
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
I've been out of school for a little bit (dusts off old notebook) ;) and I can't test this for you, but this might help...

//are you starting your timer?
t=30
timeLabel.Text = "30"
Timer1.Start()

If t > 0 Then
t -= 1
Label8.Text = t & " seconds"

Else
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("Time's up mon fracky")
inc = inc + 1 //what does this integer declare? This might be the wrong place
NavigateRecords() //I'd need to see this sub

End If

End Sub
 

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
inc is just a variable declared as Dim inc as Integer

the sub for NavigateRecords() are the following

Private Sub NavigateRecords()
TextBox1.Text = ds.Tables("emp").Rows(inc).Item(0)
TextBox2.Text = ds.Tables("emp").Rows(inc).Item(1)
TextBox3.Text = ds.Tables("emp").Rows(inc).Item(2)
End Sub

about the inc variable, its just a helps in incrmenting the questions/records in this code.

well there u have it..... :)
 

gamahiro

Active member
Supreme
Joined
Jul 8, 2010
Messages
32,579
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
Let me make sure I understand;
Code:
If t > 0 Then
t -= 1
Label8.Text = t & " seconds"

Else
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("Time's up mon fracky")
inc = inc + 1 
NavigateRecords() 

End If

End Sub
This works, but there's no loop? The timer stays at zero after the NavigateRecords()? Where are you starting your timer?
Code:
t=30
timeLabel.Text = "30"
Timer1.Start()
 

Kushan

Active member
Veteran
Joined
Jun 13, 2008
Messages
2,322
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Let me make sure I understand;
Code:
If t > 0 Then
t -= 1
Label8.Text = t & " seconds"

Else
Timer1.Stop()
timeLabel.Text = "Time's up!"
MessageBox.Show("Time's up mon fracky")
inc = inc + 1 
NavigateRecords() 

End If

End Sub
This works, but there's no loop? The timer stays at zero after the NavigateRecords()? Where are you starting your timer?
Code:
t=30
timeLabel.Text = "30"
Timer1.Start()
it's as Gama says, you don't have a syntax error it's more of a logical error, you've created that function, when doest it activate, maybe looking to storing it as a stored proc and call it where ever you need or do as Gama says and create it with in a loop;

hope this helps
 

Orion

Active member
Regular
Joined
Dec 13, 2008
Messages
1,832
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
Wat Gama says above is correct
In other words.

are you trying a countdown timer, and do you want to show time on your forum?
If yes
u can timespan function of datetime datatype.
Start the timer.
Then I think using For Loop, u can change value of text.
use function. timespan say ts.
ts.Seconds.ToString().
Hope this helps...
 

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
the timer starts countdow on form load i.e timer is enabled on form load.....when the countdown reaches at zero ... the question changes but the the countdown remains zero...the loop idea above sounds good but it would be better if any code is given with a little description ...

Thank you all for your efforts.. xd
 

Orion

Active member
Regular
Joined
Dec 13, 2008
Messages
1,832
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
the timer starts countdow on form load i.e timer is enabled on form load.....when the countdown reaches at zero ... the question changes but the the countdown remains zero...the loop idea above sounds good but it would be better if any code is given with a little description ...

Thank you all for your efforts.. xd
Do you want to show count down on your Form

:confused: :confused: .... how to send ?? i have never send anything to anyone in NB ..... and i don't stay much on NB :eek:
Gama has given his Email ID. Take your *.VBP file and zip and mail it to Gama's ID.
Since my work do not involves VB. I dont have it at my workplace.
 

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
orion... when i try to mail from here ....it doesn't give me an option for attching any files...so how am i suppose to send him the .rar file ??
 

Orion

Active member
Regular
Joined
Dec 13, 2008
Messages
1,832
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
yes i want to show my countdown timer in label8.text......thnx for the help
Try this.
Dim timercount As Integer = 30
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
lblOutput.Text = timercount.ToString() 'show the countdown in the label
If timercount = 0 Then 'Check to see if it has reached 0, if yes then stop timer and display done
Timer1.Enabled = False
lblOutput.Text = "Please answer the next question"
//Or you can insert your question as Lable Text or just make invisible.
Else If timercount > 0
timercount -= 1
End If
End Sub
It should Work, If not then combine it with For Loop. and use integer to match value with timer.
orion... when i try to mail from here ....it doesn't give me an option for attching any files...so how am i suppose to send him the .rar file ??
use some other portal like Gmail or Yahoo!.
 
Last edited:

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
actually its a little big and there are many forms for this quiz system i'm making ... i'll just paste the whole code for the form that need timer.....

Public Class web
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim ds1 As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim Sql As String
Dim MaxRows As Integer
Dim inc As Integer
Dim t As Integer = 10


Private Sub vbnet_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Timer1.Enabled = True
Label3.Text = main.TextBox1.Text
Label7.Text = main.TextBox2.Text
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
Button3.Enabled = False
Button2.Enabled = False
main.Hide()

con.ConnectionString = db

con.Open()
Sql = "SELECT * FROM web"

da = New OleDb.OleDbDataAdapter(Sql, con)
da.Fill(ds, "question1")

con.Close()

inc = 0
NavigateRecords()

Label6.Text = ds.Tables("question1").Rows(inc).Item(1)
TextBox1.Text = ds.Tables("question1").Rows(inc).Item(2)
TextBox2.Text = ds.Tables("question1").Rows(inc).Item(3)
TextBox3.Text = ds.Tables("question1").Rows(inc).Item(4)

MaxRows = ds.Tables("question1").Rows.Count
inc = -1
End Sub

Private Sub NavigateRecords()

Label6.Text = ds.Tables("question1").Rows(inc).Item(1)
TextBox1.Text = ds.Tables("question1").Rows(inc).Item(2)
TextBox2.Text = ds.Tables("question1").Rows(inc).Item(3)
TextBox3.Text = ds.Tables("question1").Rows(inc).Item(4)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If inc <> MaxRows - 1 Then
inc = inc + 1
TextBox4.Text = ""
NavigateRecords()
Else
MsgBox("No More Rows")
End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If inc > 0 Then
inc = inc - 1
NavigateRecords()
Else
MsgBox("First Record")
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If inc <> MaxRows - 1 Then
inc = MaxRows - 1
NavigateRecords()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If inc <> 0 Then
inc = 0
NavigateRecords()
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If (t > 0) Then
Label8.Text = t & " secs left"
t = t - 1
Else

Timer1.Enabled = False
MsgBox("Time up")
inc = inc + 1
NavigateRecords()

End If


End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub

Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
web_aud.Show()
Me.Hide()
web_aud.Button2.Enabled = False
web_aud.Button3.Enabled = False
web_aud.Button1.Enabled = True
web_aud.Button4.Enabled = True
End Sub

Private Sub UpdateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UpdateToolStripMenuItem.Click
web_aud.Show()
Me.Hide()
web_aud.Button1.Enabled = False
web_aud.Button4.Enabled = False
web_aud.Button3.Enabled = False
web_aud.Button2.Enabled = True
End Sub

Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
web_aud.Show()
Me.Hide()
web_aud.Button1.Enabled = False
web_aud.Button4.Enabled = False
web_aud.Button2.Enabled = False
web_aud.Button3.Enabled = True
End Sub

Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked
Timer1.Enabled = False
End Sub

End Class
 

gamahiro

Active member
Supreme
Joined
Jul 8, 2010
Messages
32,579
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
Awards
If none of the following looks vaguely familiar to you, I would pick up a book (or search online) on programming logic and design. I think I would be doing you more harm than good if I simply typed out the BASIC, rather than explain the thought process behind the logic. I hope this helps. As always, just ask if you have a question.

Main
start
housekeep() //define - declare the timer here
while not eof /ie; if it's not the last question (ex: I have 30 question)
STOP THE TIMER!!!!!!!!!! (either here) O.O
do main_loop()
endwhile
finish()
stop

housekeep()
declare variables
blah1
blah2
blah3
etc
open files
return

main_loop()
STOP THE TIMER!!!!!!!!!!! (or here...whatever works for you) O.O
if question < 31
load the next question
START THE TIMER!!!!!!!!!!!! :D
else finish()
endif
return

finish()
print score
print message
whatever
return
 

~Tahir~

Active member
Regular
Joined
Oct 7, 2009
Messages
1,456
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
xd this gives me 50% answer for my problem....anyways i've given my assigment to the teacher with only the timer not working.....hope she doesn't notices it :D .....thnx all of your for your help
 
Top