Hi guys

Just a simple question from a newbee..

In VB.net I can use "dim t as new timer" in a windows application, but not in a wpfbrowser application.
It says that "Typ timer is not defined"
anything else in the program seem to funktion. Please if anyone have a suggestion !!!

CODE:
Class Page1
Dim klicka As Integer
Dim send As String
Public Declare Sub Out Lib "DllPort.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)
Public Declare Function Inp Lib "DllPort.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Dim PortData ' variable for data at port
Dim t1 As New Timer
Dim t2 As New Timer
Dim t3 As New Timer
Dim TargetFile As System.IO.StreamWriter
Const AddressLPT1 = &H378 'Constant for position of Printer Port 1(LPT1) and Data Port
Const Statusport1 = AddressLPT1 + 1 ' Constant for position of Status Port(LPT1))
Const Controlport1 = AddressLPT1 + 2 ' Constant for position of Control Port (LPT1))
Public Sub trycka()
If Not TextBox10.Text = "CONNECTED TO SAFE" Or Not TextBox10.Text = "CONNECTION TO SAFE IS CLOSED" And TextBox10.Text = "xxx" Then
ElseIf TextBox1.Text = "" Then
TextBox1.Text = klicka

ElseIf TextBox2.Text = "" Then
TextBox2.Text = klicka

ElseIf TextBox3.Text = "" Then
TextBox3.Text = klicka

ElseIf TextBox4.Text = "" Then
TextBox4.Text = klicka

ElseIf TextBox5.Text = "" Then
TextBox5.Text = klicka

ElseIf TextBox6.Text = "" Then
TextBox6.Text = klicka

ElseIf TextBox7.Text = "" Then
TextBox7.Text = klicka

ElseIf TextBox8.Text = "" Then
TextBox8.Text = klicka

End If
End Sub

Private Sub ButtonA_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonA.Click
klicka = "10"
trycka1()
End Sub
Private Sub trycka1()
If TextBox10.Text = "xxx" Or TextBox10.Text = "CONNECTION TO SAFE IS CLOSED" And klicka = "10" Then
t1.Interval = 20
AddHandler t1.Tick, AddressOf Me.t_ShowProgress1
t1.Start()
End If
End Sub
Private Sub t_ShowProgress1()
ProgressBar1.Value += 1
TextBox10.Text = ("xxx")
If ProgressBar1.Value = 100 Then
TextBox10.Text = ("xxx")
t1.Stop()
ProgressBar1.Value = 0
MessageBox.Show("xxx")
End If
End Sub
Private Sub Buttonopen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonopen.Click
klicka = "12"
trycka2()
End Sub
Private Sub trycka2()
If klicka = "12" And Not TextBox1.Text = "" And Not TextBox2.Text = "" And Not TextBox3.Text = "" And Not TextBox4.Text = "" Then
t2.Interval = 200
AddHandler t2.Tick, AddressOf Me.t_ShowProgress2
'AddHandler t2.Tick, AddressOf Me.t_ShowTime
t2.Start()
End If
End Sub

Private Sub t_ShowProgress2()
ProgressBar1.Value += 1
If ProgressBar1.Value = 100 Then
ProgressBar1.Value = 0
t2.Stop()
TextBox11.Text = ("xxx")
TextBox10.Text = ("xxx")
End If
End Sub
Private Sub Buttonchange_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonchange.Click
klicka = "11"
trycka3()
End Sub

Private Sub trycka3()
If TextBox10.Text = "xxx" Then
If klicka = "11" And Not TextBox1.Text = "" And Not TextBox2.Text = "" And Not TextBox3.Text = "" And Not TextBox4.Text = "" Then
t3.Interval = 100
AddHandler t3.Tick, AddressOf Me.t_ShowProgress3
'AddHandler t3.Tick, AddressOf Me.t_ShowTime
t3.Start()
End If
Else
MessageBox.Show("xxx")
End If
End Sub
Private Sub t_ShowProgress3()
TextBox11.Text = ("xxx")
ProgressBar1.Value += 1
End If
If ProgressBar1.Value = 100 Then
MessageBox.Show("xxx")
TextBox10.Text = ("xxx")
t3.Stop()
ProgressBar1.Value = "0"
End If
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
klicka = "1"
trycka()
End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
klicka = "2"
trycka()
End Sub

Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
klicka = "3"
trycka()
End Sub

Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
klicka = "4"
trycka()
End Sub

Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
klicka = "5"
trycka()
End Sub

Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
klicka = "6"
trycka()
End Sub

Private Sub Button7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button7.Click
klicka = "7"
trycka()
End Sub

Private Sub Button8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button8.Click
klicka = "8"
trycka()
End Sub

Private Sub Button9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button9.Click
klicka = "9"
trycka()
End Sub

Private Sub Button0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button0.Click
klicka = "0"
trycka()

End Sub
End Class

The issue is because a normal ASP.NET page executes server side. Timers are run client side. You can use a timer on a webpage, but you need to use AJAX.

Go to www.asp.net and download the AJAX extension for VS 2005. You will then see the timer control.

Best/Eric

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.