Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 VB.NET - Arraylist, how to remove ?

views
     
TSnaim_mahmood
post Mar 3 2006, 11:54 AM, updated 20y ago

Getting Started
**
Junior Member
105 posts

Joined: Jul 2005


   'Written by Chevol A. Davis
   'display the current date and time
   Private nextAlarmTimes As New ArrayList

   Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
       TextBox1.Text = System.DateTime.Now
   End Sub

   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       'enable the timer set to 1000 which is equal to a second
       Timer1.Enabled = True
       Me.nextAlarmTimes.Add(System.DateTime.Now.AddSeconds(8))
   End Sub

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
       'for every click of the timer (1 sec.) update the date and time
       TextBox1.Text = System.DateTime.Now

       Dim alarmTime As Date

       For i As Integer = 0 To Me.nextAlarmTimes.Count - 1 Step 1
           alarmTime = CDate(Me.nextAlarmTimes(i))

           If System.DateTime.Now > alarmTime Then
               System.Diagnostics.Process.Start("http://www.google.com")
               Me.nextAlarmTimes.Remove(0)
           End If
       Next

   End Sub


Anyone please help me.
The source code above is a timer program which will open IE to google.com 8 second after run this program.

the problem is i already remove the the time from arraylist BUT.. the program will always open IE to google every 8 sec .!

How's this possible..... pls help

This post has been edited by naim_mahmood: Mar 5 2006, 05:37 PM
sinx
post Mar 3 2006, 12:52 PM

New Member
*
Junior Member
15 posts

Joined: Aug 2005


In your case,

try to change
from
Me.nextAlarmTimes.Remove(0)
to
Me.nextAlarmTimes.RemoveAt(0)
lighching
post Mar 4 2006, 12:40 PM

Regular
******
Senior Member
1,348 posts

Joined: Nov 2004
From: Red Planet. NeverLand Area 7
since the ArrayList only have 1 item, just clear the ArrayList item.

or

stop the timer1.

or

set the timer1 to 8000 and than open http://www.google.com than stop the timer.

CODE

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
          System.Diagnostics.Process.Start("http://www.google.com")
          Timer1.stop
End Sub

TSnaim_mahmood
post Mar 5 2006, 01:18 PM

Getting Started
**
Junior Member
105 posts

Joined: Jul 2005


Thanks for the feedback guys smile.gif

 

Change to:
| Lo-Fi Version
0.0157sec    0.55    5 queries    GZIP Disabled
Time is now: 24th December 2025 - 01:23 AM