Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42457

VS 2010 Timer is not stopping and Pop-up windows appearing infinitely

$
0
0
I have here my code to send SMS:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
count = DataTable1DataGridView.Rows.Count
For i As Integer = count To 1 Step -1
Try
If SerialPort1.IsOpen Then
'dataGridView1()
' TextBox1.Text = Me.dataGridView1.Rows(0).Cells(2).Value.ToString()
With SerialPort1
.Write("AT" & vbCrLf)
.Write("AT+CMGF=1" & vbCrLf)
.Write("AT+CMGS=" & Chr(34) & DataTable1DataGridView.Rows(i - 1).Cells(2).Value.ToString & Chr(34) & vbCrLf)
.Write(ES_MSG.Rows(0).Cells(0).Value.ToString & Chr(26))
End With
Else
MsgBox("Error on the port selected")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
If (i = count) Then
Exit For
Timer1.Enabled = False
Timer1.Stop()
End If
MsgBox("Message Sent!")
Next
Timer1.Enabled = False
Timer1.Stop()
End Sub

I have enabled timer through a button_click. My problem is timer doesn't seem to stop no matter where I put the Timer.Stop() and Timer.Enabled = False. The worse is when there are errors or when the message is sent, the pop-up seems to appear infinitely even if the count from my datagrid is just small. Can anyone share ideas? I really need it. Thanks.

Viewing all articles
Browse latest Browse all 42457

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>