true people count with webbrowser - webbrowser-control

We have true people count AXI cameras that count the number of people enter the building. we can see live view and the count in\out on webpage. I wanna display the count result on a screen without any animations. I thought about using a webbrowser control in vb.net to load the live view webpage and then inject the javascript in webbrowser and show the count on textbox. here is my code but I keep getting error messages on the javascript text, any help apprecited
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WebBrowser3.Navigate("http://10.xx.xxx.xx/people-counter/liveview.html"
Private Sub WebBrowser3_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser3.DocumentCompleted
Dim mScript As HtmlElement
Dim mHead As HtmlElement
Dim element As mshtml.HTMLScriptElement
With WebBrowser3
mHead = WebBrowser3.Document.GetElementsByTagName("head")(0)
mScript = .Document.CreateElement("script")
mScript.SetAttribute("type", "text/javascript")
element = mScript.DomElement
element.text = "$(function showcount(){$("#video").countingArea($.extend({},cntarea,{displayWidth:320,displayHeight:240,mjpgUrl:"/axis-cgi/mjpg/video.cgi?resolution=320x240",jpegUrl:"/local/people-counter/.api?image.jpg",fps:12}));$.liveviewWithTable({countsTableElement:$("#counts"),countTableElement:$("#count"),directionIn:$.getParam("Counter.DirectionIn"),liveSumUrl:"/local/people-counter/.api?live-sum.json",loadingAnimationUrl:"/people-counter/images/ajax-loader.gif",dataTypes:["in","out"],strings:{"x second ago":"%d second ago","x seconds ago":"%d seconds ago","x minute ago":"%d minute ago","x minutes ago":"%d minutes ago","x hour ago":"%d hour ago","x hours ago":"%d hours ago","x day ago":"%d day ago","x days ago":"%d days ago","x week ago":"%d week ago","x weeks ago":"%d weeks ago","x month ago":"%d month ago","x months ago":"%d months ago","x year ago":"%d year ago","x years ago":"%d years ago"}})});"
mHead.AppendChild(mScript)
.Document.InvokeScript("showcount")
End With
End Sub

Related

Is there a way to overlay sound2 on sound1 between specific timeframe?

Suppose sound1 is 10 mins long and I would like to overlay sound2 (3mins) between 7:00 till 9:00 mins (only first 2 mins of sound2)?

Make part of a shape/text with no fill

I am working on a countdown timer in VBA Powerpoint which takes the input of hour, minutes and seconds and calculate the remaining time which simply counts down to 0
The Working Code:
Sub countdown()
Dim time As Date
hours = InputBox("Hour")
minutes = InputBox("Minutes")
seconds = InputBox("Seconds")
time = Date + TimeSerial(hours, minutes, seconds)
Do Until time < Now()
DoEvents
ActivePresentation.Slides(1).Shapes("startIn").TextFrame.TextRange = "Începem în:"
ActivePresentation.Slides(1).Shapes("countdown").TextFrame.TextRange = Format((time - Now()), "hh:mm:ss")
Loop
End Sub
Now I am trying to hide the hours in my PowerPoint presentation and I tried to make the text fill of just hours with no fill and didn't succeded.. what should I do? I tried this:
ActivePresentation.Slides(1).Shapes("countdown").TextFrame.TextRange.Find("hh:").
But from here I was stuck...
I tried to find just the hours part of text in the countdown shape and to make text with no fill.
I am a begginer in VBA.
This is the timer I created in PowerPoint:
For minutes in VBA is better to use nn instead of mm, mm is for months, and nn is for minutes. So that's why I used Format((time - Now()), "mm:ss") and I got a 12 instead of minutes, because that was the month. When I put this code Format((time - Now()), "nn:ss") I got the minutes and the macro worked well.

vb.net Refresh DatePicker value after everyday

I have this code under a Timer's tick event to refresh the value of a DateTimePicker after everyday/at 7:19 (tTmNow)
`Private Sub tmrNewDay_Tick(sender As Object, e As EventArgs) Handles tmrNewDay.Tick
If tTmNow.Text.Contains("7:19:") Then 'at this time pick yesterday's date
Dim ystd As String
ystd = Today.AddDays(-1) 'yesterday
dtPicker1.Value = ystd 'put yesterday's date into the date time picker
End If
End Sub`
Unfortunately, at the first run of the program, I achieve my aim successfully. But the second day (The program is to run everyday and pick yesterday's date), when picking the date, it adds the time; giving 19-04-2017 00:00:00, instead of 19-04-2017. Is there a way to refresh the contents of the DateTimePicker or is there an entirely new way of picking yesterday's date, day after day.

How to send the datetimepicker value to textbox, only when clicking the date, specific days or year of the month

Everytime I double click the datetimepicker, it automatically send its values to the textbox. Now, I want to send the value of DateTimePicker in the Textbox, only when I click the date, specific days or year of the month?
Here's my vb.net code:
Private Sub DateTimePicker1_DOB_CloseUp(sender As Object, e As EventArgs) Handles DateTimePicker1_DOB.CloseUp
TextBox1_Date.Text = DateTimePicker1_DOB.Text
End Sub

Calculate age in years, months or days in textbox w/datetimepicker

my question is how can I calculate age using datetimepicker in another textbox?
e.g. If user picks a 10/06/2014 date assuming today is 11/06/2014, textbox should show "1 day"
or if user picks 02/03/2014, txtbox should show "3 months"
This is my code for calculate age in years
Private Sub BirthDate_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BirthDate.ValueChanged
txtAge.Text = Fix((DateDiff(DateInterval.Day, BirthDate.Value, Now.Date)) / 365) & " years"
End Sub
Thanks in advance!
Check out the DateDiff specification: http://msdn.microsoft.com/en-us/library/b5xbyt6f%28v=vs.90%29.aspx
You're already using it, but if you want years, you don't need to divide the days by 365, you can use DateInterval.Year.
You can apply the same thing to other time intervals, you'll need to set parameters for when you'd like to use each.
For example (pseudocode):
if DateDiff(DateInterval.Day, Birthdate.Value, Now.Date) < 30
print DateDiff(DateInterval.Day, Birthdate.Value, Now.Date)
elseif 29 < DateDiff(DateInterval.Day, Birthdate.Value, Now.Date) < 365
print DateDiff(DateInterval.Month, Birthdate.Value, Now.Date)
elseif DateDiff(DateInterval.Day, Birthdate.Value, Now.Date) > 365
print DateDiff(DateInterval.Year, Birthdate.Value, Now.Date)
I hope this helps!