943,673 Members | Top Members by Rank

Ad:
Dec 1st, 2008
0

Countdown Timer

Expand Post »
Hi, I would like to create a countdown timer using number extracted from the database to use a the time for the countdown. Can anyone help me ?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
joeey is offline Offline
8 posts
since Jul 2008
Dec 1st, 2008
0

Re: Countdown Timer

Not really sure what you are looking for, please give more details. You can create a countdown using a loop. If you want to add or subtract a number from a date, use dateadd() function.
Reputation Points: 20
Solved Threads: 10
Junior Poster
aparnesh is offline Offline
193 posts
since Jul 2005
Dec 1st, 2008
0

Re: Countdown Timer

can you please explain a bit in detail.
Featured Poster
Reputation Points: 665
Solved Threads: 427
Posting Genius
debasisdas is offline Offline
6,406 posts
since Feb 2007
Dec 29th, 2008
0

Re: Countdown Timer

Sorry for the long delay. I'll explain about the project I'm doing. I'm trying to create a SMS based reminder application using visual basic and a GSM modem. Currently, the program has the ability to send, extract, receive and store. Now I would like to enable the program to send a reminder using the time stored in the database. For example, if the user sends 10# tower, this would be saved in the database as 10 under the hour column, User's Handphone number would be under Numbers and tower under Message. Once 10 hours are up, the program would send an SMS back to the user.

Below is the code for the program
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Public Class Form1
  2. Dim TotalRows As Integer
  3. Dim NextRecord As Integer
  4. Dim ConObject As New OleDb.OleDbConnection
  5. Dim dSet As New DataSet
  6. Dim dAdapter As OleDb.OleDbDataAdapter
  7. Dim Sel As String
  8.  
  9. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  10. ConObject.ConnectionString = "PROVIDER=MICROSOFT.Jet.OLEDB.4.0;Data Source= C:\Documents and Settings\Telematics\My Documents\061514U Edmund\lab_3\ProjectDB.mdb"
  11.  
  12. ConObject.Open()
  13. Sel = "SELECT*FROM Table1"
  14. dAdapter = New OleDb.OleDbDataAdapter(Sel, ConObject)
  15. dAdapter.Fill(dSet, "ProjectDB")
  16. ConObject.Close()
  17.  
  18. TotalRows = dSet.Tables("ProjectDB").Rows.Count
  19. End Sub
  20.  
  21.  
  22. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  23. Call ModemMode()
  24.  
  25.  
  26. End Sub
  27. Private Sub ModemMode()
  28. If SerialPort1.IsOpen Then
  29. SerialPort1.Close()
  30. End If
  31.  
  32. SerialPort1.PortName = "COM1"
  33. SerialPort1.BaudRate = 115200
  34. SerialPort1.Parity = IO.Ports.Parity.None
  35. SerialPort1.DataBits = 8
  36. SerialPort1.StopBits = IO.Ports.StopBits.One
  37. SerialPort1.RtsEnable = True
  38.  
  39. SerialPort1.Open()
  40.  
  41. SerialPort1.WriteLine("AT+CMGF=1" + vbCr)
  42. WaitForm.ShowDialog()
  43.  
  44. TextBox1.Text = ""
  45. TextBox1.Text = SerialPort1.ReadExisting
  46.  
  47. If InStr(TextBox1.Text, "OK") <> 0 Then
  48. MessageBox.Show("Successful(CMGF)!")
  49. Else
  50. MessageBox.Show("Try again")
  51. End If
  52.  
  53. TextBox1.Text = ""
  54. SerialPort1.WriteLine("AT+CNMI=0,1,0,0,0" + vbCr)
  55. WaitForm.ShowDialog()
  56. WaitForm.ShowDialog()
  57.  
  58. TextBox1.Text = SerialPort1.ReadExisting
  59.  
  60. If InStr(TextBox1.Text, "OK") <> 0 Then
  61. MessageBox.Show("Successful(CNMI)!")
  62. Else
  63. MessageBox.Show("Try again")
  64. End If
  65.  
  66. SerialPort1.Close()
  67. End Sub
  68.  
  69. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  70. Call ReadSMS()
  71.  
  72.  
  73. End Sub
  74. Private Sub ReadSMS()
  75.  
  76. If SerialPort1.IsOpen Then
  77. SerialPort1.Close()
  78. End If
  79.  
  80. SerialPort1.PortName = "COM1"
  81. SerialPort1.BaudRate = 115200
  82. SerialPort1.Parity = IO.Ports.Parity.None
  83. SerialPort1.DataBits = 8
  84. SerialPort1.StopBits = IO.Ports.StopBits.One
  85. SerialPort1.RtsEnable = True
  86.  
  87. SerialPort1.Open()
  88.  
  89.  
  90. SerialPort1.WriteLine("AT+CMGR=" + TextBox2.Text + vbCr)
  91.  
  92. System.Threading.Thread.Sleep(500)
  93. TextBox1.Text = ""
  94. TextBox1.Text = SerialPort1.ReadExisting
  95.  
  96. SerialPort1.Close()
  97.  
  98.  
  99. End Sub
  100.  
  101. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  102.  
  103. If SerialPort1.IsOpen Then
  104. SerialPort1.Close()
  105. End If
  106.  
  107. SerialPort1.PortName = "COM1"
  108. SerialPort1.BaudRate = 115200
  109. SerialPort1.Parity = IO.Ports.Parity.None
  110. SerialPort1.DataBits = 8
  111. SerialPort1.StopBits = IO.Ports.StopBits.One
  112. SerialPort1.RtsEnable = True
  113.  
  114. SerialPort1.Open()
  115.  
  116. SerialPort1.WriteLine("AT+CMGD=1,4" + vbCr)
  117. TextBox1.Text = vbNewLine & "...in progress..."
  118. TextBox1.Refresh()
  119. System.Threading.Thread.Sleep(4000)
  120. System.Threading.Thread.Sleep(4000)
  121. System.Threading.Thread.Sleep(4000)
  122.  
  123. TextBox1.Text = ""
  124. TextBox1.Text = SerialPort1.ReadExisting
  125. SerialPort1.Close()
  126.  
  127. End Sub
  128.  
  129. Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  130. Call DeleteOneSMS()
  131. End Sub
  132. Private Sub DeleteOneSMS()
  133. If SerialPort1.IsOpen Then
  134. SerialPort1.Close()
  135. End If
  136.  
  137. SerialPort1.PortName = "COM1"
  138. SerialPort1.BaudRate = 115200
  139. SerialPort1.Parity = IO.Ports.Parity.None
  140. SerialPort1.DataBits = 8
  141. SerialPort1.StopBits = IO.Ports.StopBits.One
  142. SerialPort1.RtsEnable = True
  143.  
  144. SerialPort1.Open()
  145.  
  146. SerialPort1.WriteLine("AT+CMGD=" + TextBox6.Text + vbCr)
  147. TextBox1.Text = vbNewLine & "...in progress..."
  148. TextBox1.Refresh()
  149. System.Threading.Thread.Sleep(1250)
  150.  
  151. TextBox1.Text = ""
  152. TextBox1.Text = SerialPort1.ReadExisting
  153.  
  154. SerialPort1.Close()
  155. End Sub
  156.  
  157. Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  158. Call SendSMS()
  159. End Sub
  160. Private Sub SendSMS()
  161. If SerialPort1.IsOpen Then
  162. SerialPort1.Close()
  163. End If
  164.  
  165. SerialPort1.PortName = "COM1"
  166. SerialPort1.BaudRate = 115200
  167. SerialPort1.Parity = IO.Ports.Parity.None
  168. SerialPort1.DataBits = 8
  169. SerialPort1.StopBits = IO.Ports.StopBits.One
  170. SerialPort1.RtsEnable = True
  171.  
  172. SerialPort1.Open()
  173.  
  174. SerialPort1.WriteLine("AT+CMGS=" + TextBox3.Text + vbCr)
  175. TextBox1.Text = vbNewLine & "...SMS sending in progress..."
  176. TextBox1.Refresh()
  177. System.Threading.Thread.Sleep(750)
  178. SerialPort1.WriteLine(TextBox4.Text)
  179. System.Threading.Thread.Sleep(500)
  180. SerialPort1.WriteLine(Chr(26))
  181. System.Threading.Thread.Sleep(5500)
  182.  
  183. TextBox1.Text = ""
  184. TextBox1.Text = SerialPort1.ReadExisting
  185.  
  186. If InStr(TextBox1.Text, "OK") <> 0 Then
  187. TextBox1.Text = "SMS message successfully sent!"
  188. MessageBox.Show("SMS message successfully sent!")
  189. Else
  190. MessageBox.Show("Try again")
  191. End If
  192.  
  193. SerialPort1.Close()
  194. End Sub
  195.  
  196. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  197. TextBox5.Text = TextBox4.Text.Length
  198. If TextBox5.Text > 160 Then
  199. Beep()
  200. End If
  201.  
  202.  
  203. End Sub
  204.  
  205.  
  206. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  207.  
  208. End Sub
  209. Private Sub ExtractPhoneNumber()
  210. If SerialPort1.IsOpen Then
  211. SerialPort1.Close()
  212. End If
  213.  
  214. SerialPort1.PortName = "COM1"
  215. SerialPort1.BaudRate = 115200
  216. SerialPort1.Parity = IO.Ports.Parity.None
  217. SerialPort1.DataBits = 8
  218. SerialPort1.StopBits = IO.Ports.StopBits.One
  219. SerialPort1.RtsEnable = True
  220.  
  221. SerialPort1.Open()
  222.  
  223. Dim str1
  224. Dim str2
  225. Dim Extract As String
  226.  
  227. str1 = TextBox1.Text
  228. str2 = str1.Split("D")
  229. TextBox7.Text = str2(1)
  230.  
  231. Extract = TextBox7.Text.Substring(3, 11)
  232. TextBox7.Text = Extract
  233. End Sub
  234.  
  235. Private Sub ExtractMessage()
  236. If SerialPort1.IsOpen Then
  237. SerialPort1.Close()
  238. End If
  239.  
  240. SerialPort1.PortName = "COM1"
  241. SerialPort1.BaudRate = 115200
  242. SerialPort1.Parity = IO.Ports.Parity.None
  243. SerialPort1.DataBits = 8
  244. SerialPort1.StopBits = IO.Ports.StopBits.One
  245. SerialPort1.RtsEnable = True
  246.  
  247. SerialPort1.Open()
  248.  
  249. Dim str3
  250. Dim str4
  251. Dim Extract2 As String
  252. Dim Extract3 As String
  253.  
  254. str3 = TextBox1.Text
  255. str4 = str3.Split("#")
  256. TextBox8.Text = str4(1)
  257.  
  258. Extract2 = TextBox8.Text.Substring(2)
  259. Extract3 = TextBox8.Text.Substring(0, 2)
  260. TextBox8.Text = Extract2
  261. TextBox9.Text = Extract3
  262. End Sub
  263.  
  264. Private Sub button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button6.Click
  265. Call ExtractMessage()
  266. Call ExtractPhoneNumber()
  267. End Sub
  268.  
  269.  
  270.  
  271. Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  272. TextBox1.Text = ""
  273. TextBox2.Text = ""
  274. TextBox3.Text = ""
  275. TextBox4.Text = ""
  276. TextBox5.Text = ""
  277. TextBox6.Text = ""
  278. TextBox7.Text = ""
  279. TextBox8.Text = ""
  280. TextBox9.Text = ""
  281.  
  282.  
  283.  
  284. End Sub
  285.  
  286. Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
  287. Dim cBuilder As New OleDb.OleDbCommandBuilder(dAdapter)
  288. Dim dsNewRow As DataRow
  289.  
  290. dsNewRow = dSet.Tables("ProjectDB").NewRow()
  291. dsNewRow.Item("Numbers") = TextBox7.Text
  292. dsNewRow.Item("Message") = TextBox8.Text
  293. dsNewRow.Item("Hours") = TextBox9.Text
  294. dSet.Tables("ProjectDB").Rows.Add(dsNewRow)
  295. dAdapter.Update(dSet, "ProjectDB")
  296. dSet.Clear()
  297. dAdapter.Fill(dSet, "ProjectDB")
  298. MsgBox("Data Stored!")
  299.  
  300. End Sub
  301. End Class
Reputation Points: 10
Solved Threads: 0
Newbie Poster
joeey is offline Offline
8 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Saving Mshflexgrid data columnwise in a table
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: urjent-barcode reader





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC