Problem with DateTime.Now.ToString
Hi,
I'm trying to do this :
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If DateTime.Now.ToString("dddd") = "Sun" Then
Label1.Text = "Sun"
ElseIf DateTime.Now.ToString("dddd") = "Mon" Then
Label1.Text = "Mon"
ElseIf DateTime.Now.ToString("dddd") = "Tue" Then
Label1.Text = "Tue"
ElseIf DateTime.Now.ToString("dddd") = "Wed" Then
Label1.Text = "Wed"
ElseIf DateTime.Now.ToString("dddd") = "Thu" Then
Label1.Text = "Thu"
ElseIf DateTime.Now.ToString("dddd") = "Fri" Then
Label1.Text = "Fri"
ElseIf DateTime.Now.ToString("dddd") = "Sat" Then
Label1.Text = "Sat"
Else
Label1.Text = Nothing
End If
End Sub
But after 23:59:59, label1.text doesn't change to the next day.
any suggestions ?
Re: Problem with DateTime.Now.ToString
What's with all that code?
vb.net Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = DateTime.Now.ToString("ddd")
End Sub
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
dunfiddlin
What's with all that code?
vb.net Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = DateTime.Now.ToString("ddd")
End Sub
You are right, I don't need all that code to show the day, I need it like this :
vb.net Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Label1.Text = "DAY-OF-WEEK1" then
--do-whatever1
ElseIf If Label1.Text = "DAY-OF-WEEK2" then
--do-whatever2
End
End Sub
Thanks!
What I actually need is this :
Quote:
If Time-and-Date = Time-and-Date in the DB then tell Asterisk to call Extension xxx > play a 5sec beep > hangup
I'm trying to write a School Bell System that interacts with Asterisk PBX...
Re: Problem with DateTime.Now.ToString
Check out the DateTime.DayOfWeek property.
vb Code:
Select Case DateTime.Today.DayOfWeek
Case DayOfWeek.Monday
Case DayOfWeek.Tuesday
Case DayOfWeek.Wednesday
Case DayOfWeek.Thursday
Case DayOfWeek.Friday
End Select
How do you have the times stored in the DB?
Re: Problem with DateTime.Now.ToString
This did the trick :
Code:
Label1.Text = DateTime.Now.ToString("ddd")
the label is changing.
Thanks
so it is like this :
Code:
if label1.text = Mon or Tue or Wed or Thu then '(day of week)
goto a #Region for M-T
ElseIf label1.text = Fri then
goto a #Region for Fri
In the #Region there will be a database roe times...
Quote:
Originally Posted by
JuggaloBrotha
How do you have the times stored in the DB?
I don't have a database yet...
That will be a challenge...
Do you have any suggestions ?
Re: Problem with DateTime.Now.ToString
Is there anything more to go in than 2 schedules eg.
Normal, 09.00, 10.00, 11.00 etc.
Friday, 09.10, 10.00, 11.00 etc. ?
If not I'm not sure I'd even bother with a database. A simple text file would be more than adequate (and easily edited) with the advantage that you have complete control over the formatting.
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
dunfiddlin
Is there anything more to go in than 2 schedules eg.
Normal, 09.00, 10.00, 11.00 etc.
Friday, 09.10, 10.00, 11.00 etc. ?
If not I'm not sure I'd even bother with a database. A simple text file would be more than adequate (and easily edited) with the advantage that you have complete control over the formatting.
It is not that simple, there is 4 or 5 groups of bell times
Or maybe you are right, like this:
if time = 09:00 page group 1 (with class 1>6)
if time = 09:30 page group 2 (with class 6>10 and outside)
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
threeeye
It is not that simple, there is 4 or 5 groups of bell times
Or maybe you are right, like this:
if time = 09:00 page group 1 (with class 1>6)
if time = 09:30 page group 2 (with class 6>10 and outside)
What I would do is create an Access database that has 2 columns: Integer (for the day of the week; Sunday is 0, Saturday is 6), Text (to hold the time, I would recommend the time portion use 24 hour time to make things easier). Then I would fill it with each of the day's times the "bell" should ring. For example if the bell rings at 8am M-F, 9am M, W, F and so on there would be these records in the table:
1,08:00
1,09:00
2,08:00
3,08:00
3,09:00
4,08:00
5,08:00
5,09:00
Then when you query that table to get the times for that particular day, just pass it the DateTime.Now.DayOfWeek (which is an integer) and you'll get the times for that day.
Then it's just a matter of having a timer (tick interval set to 5000 (5 seconds)) and check the time against your list of times, if it matches one of them, then "ring" the bell.
By using a database, you can more easily incorporate a form that lets you change that "schedule" in the database, you could even include 2 date fields to have different schedules for date ranges (summer classes vs fall classes) and so on.
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
JuggaloBrotha
What I would do is create an Access database that has 2 columns: Integer (for the day of the week; Sunday is 0, Saturday is 6), Text (to hold the time, I would recommend the time portion use 24 hour time to make things easier). Then I would fill it with each of the day's times the "bell" should ring. For example if the bell rings at 8am M-F, 9am M, W, F and so on there would be these records in the table:
1,08:00
1,09:00
2,08:00
3,08:00
3,09:00
4,08:00
5,08:00
5,09:00
Then when you query that table to get the times for that particular day, just pass it the DateTime.Now.DayOfWeek (which is an integer) and you'll get the times for that day.
Then it's just a matter of having a timer (tick interval set to 5000 (5 seconds)) and check the time against your list of times, if it matches one of them, then "ring" the bell.
By using a database, you can more easily incorporate a form that lets you change that "schedule" in the database, you could even include 2 date fields to have different schedules for date ranges (summer classes vs fall classes) and so on.
That is a good idea, but I don't know enough VB.NET A. to call 2 columns in a database, B. I have the following command :
Code:
phoneCall = Me.softPhone.CreateCallObject(phoneLine, labelDialingNumber.Text)
where "labelDialingNumber.Text" is the label with a group to "RING-A-BELL"
so before the "1,09:00" bell(before every bell, but i took this as e.g.) the "labelDialingNumber.text" needs to change to that bell...
1 Attachment(s)
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
threeeye
That is a good idea, but I don't know enough VB.NET A. to call 2 columns in a database, B. I have the following command :
Code:
phoneCall = Me.softPhone.CreateCallObject(phoneLine, labelDialingNumber.Text)
where "labelDialingNumber.Text" is the label with a group to "RING-A-BELL"
so before the "1,09:00" bell(before every bell, but i took this as e.g.) the "labelDialingNumber.text" needs to change to that bell...
Here's an example of what I was talking about with using a database for this. I used an Access 2003 database (you can use Access 2010 to edit it, just keep it in the 2002/2003 database format) to hold the data in a single table. I did my best to cover all the basics to it, you'll probably want a different edit form though, but mine at least works to get the point across.
Also it doesn't take into account where to put the database if you deploy the app (I usually have the app copy the database from the same directory into the current user's appdata folder).
Also, you'll have to plug in the code you have that actually "rings" the bell too, the app right now just displays a messagebox to indicate when the ringing happens.
Re: Problem with DateTime.Now.ToString
Hi,
This is small and simple, I love it !
The hard part is to connect it with Asterisk PBX
The code that I'm working on is a modified softphone that I found...
There is a lot of files, dll's and "Imports"
Code:
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports Ozeki.Media
Imports Ozeki.Network.Nat
Imports Ozeki.VoIP.Media
Imports Ozeki.Media.MediaHandlers
Imports Ozeki.VoIP
Imports Ozeki.VoIP.SDK
Imports Ozeki.Common
Under the "Ozeki.anything" there is a green zigzag line and a red error
Quote:
"Namespace or type specified in the Imports 'Ozeki.anything' doesn't contain any public member or cannot be found..."
I tried copying the dll's and files, but nothing
Here is a link with the original softphone and the one I modified.
https://docs.google.com/open?id=0Bwt...FpFYlpBUGZNSkE
Thank again
Re: Problem with DateTime.Now.ToString
Project > Add Reference
You can't import something that the IDE's never heard of!
Re: Problem with DateTime.Now.ToString
Quote:
Originally Posted by
dunfiddlin
Project > Add Reference
You can't import something that the IDE's never heard of!
THANKS !
In the next couple days I won't have a lot of time building this pet project (school is starting soon, and I have a lot of work ahead...)
I'll check back in a few days with an update...
Thanks again.