xrjf 230 Posting Whiz

If you have downloaded the last zip file it is plausible you have noticed a bug, when the input expression is not a valid expression. This is because in the message class 'msg8' the code of the msgN() function should be replaced by the following code:

    Private Function msgN(n As Int32, Optional Arr() As String = Nothing) As String
        Dim e1 As String = String.Empty
        Try
            Select Case n
                Case 1 : e1 = "Empty expression."
                Case 2
                    Dim sL As String = ""
                    Dim pos As Int32 = eP.iRe - 1
                    If pos > 0 Then sL = eP.sbExpr.ToString.Substring(0, pos)
                    Dim sR As String = ""
                    If pos + Join(Arr, "").Length < eP.sbExpr.Length Then
                        sR = eP.sbExpr.ToString.Substring(pos + Join(Arr, "").Length)
                    End If
                    e1 = "Token sequence: " + vbCrLf + sL + " [{0}{1}] " + sR + vbCrLf + " is not valid."
                Case 3 : e1 = "End token ""{0}"" is not valid."
                Case 4 : e1 = "Start token ""{0}"" is not valid."
                Case 5 : e1 = "n/a, the expression is incomplete/unintelligible."
                Case 6 : e1 = "n/a, token ""{0}"" is unknown or not allowed."
                    'Case 7 : e1 = "Argument out of bounds."
                Case 8 : e1 = "n/a, stack is empty."
                Case 9 : e1 = "n/a, missing one or more matching left parenthesis."
                Case 10 : e1 = "n/a, missing one or more matching right parenthesis."
                Case 11 : e1 = "n/a, could not found variable ""{0}"" or its value." …
xrjf 230 Posting Whiz

Does that mean it can have upper case? or that pattern should not be different, as in abc.xyz? That would leave only expressions like abc.abc? But that does not make to much sense. Then could it be a pattern abc.xyz, where xyz<>abc? If so, the pattern would be:

Imports System.Text.RegularExpressions

Module Module1

Sub Main()
    Dim sPattern As String = _
        "(?<ABC>(?<A>[a-z])(?<B>(?!\k<A>)[a-z])(?!\k<A>|\k<B>)[a-z])"
    Dim rePattern As New Regex( _
        sPattern + "\.(?!\k<ABC>)" + sPattern)

    Do
        Console.WriteLine("Text validation")
        Console.WriteLine("Text should be like 'abc.xyz'")
        Console.WriteLine("Text not should be like 'abc.Xyz' ")
        Console.WriteLine("Enter your text and press 'CR' (blank to exit): ")
        Dim e1 As String = Console.ReadLine()
        If e1.Length = 0 Then Exit Do
        Console.WriteLine()
        Dim m As Match = rePattern.Match(e1)
        If m.Success Then
            Console.WriteLine("Right ! " + m.ToString)
        Else
            If LCase(e1) <> e1 Then
                Console.WriteLine("Letters should be in lower case.")
            End If
            Console.WriteLine(e1 + " does not match, try again.")
        End If
        Console.WriteLine("")
    Loop
End Sub

End Module

xrjf 230 Posting Whiz

Today's release Mates8v8.4.3 is composed a zip file containing the source code (the executable is in folder ...\testMates8\testMates8\bin\Debug\testMates8.exe) and a .pdf document.

xrjf 230 Posting Whiz

If you don't mind, I would prefer to continue, if needed, the path in this thread. BTW, you should know I'm not specially versed in webbrowser subject, just have some notions.

xrjf 230 Posting Whiz

Having WebBrowser1 and WebBrowser2 in Form1

Public Class Form1

    Dim sNav2 As String = "http://www.google.com" ' your Url goes here

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        ' Initialize WebBrowser1 document:
        Dim e2 As String = ""
        e2 = "<html><head id=""hd"">" + vbCrLf
        e2 += "</head>"
        e2 += "<body id=""bd"">" + vbCrLf
        e2 += "</body></html>" + vbCrLf
        WebBrowser1.DocumentText = "<html></html>"
        WebBrowser1.Document.Write(e2)

        ' Get a string of a form:
        Dim e1 As String = "<form name=""form1"" method=""POST"" action=""" + sNav2 + """>" + vbCrLf
        e1 += "<input type=""text"" name=""sName"" value=""abcd"">" + vbCrLf
        e1 += "<input type=""submit"" name=""btnSubmit"" value=""Send"">" + vbCrLf
        e1 += "</form>" + vbCrLf

        ' Write the form into WebBrowser1:
        WebBrowser1.Document.GetElementById("bd").InnerHtml = e1
    End Sub

    Private Sub WebBrowser1_Navigating(sender As Object, e As WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
        Dim uri As System.Uri = e.Url
        If InStr(uri.AbsoluteUri, sNav2) Then
            e.Cancel = True
            WebBrowser2.Navigate(uri.AbsoluteUri)
        End If
    End Sub
End Class
xrjf 230 Posting Whiz

16dfea3fc52b71aa61803657eb9c7cf24d08b66c8f2e9dd9c45ff169a44fe198
Hoping you take advantage out of this tutorial, best regards.
Xavier.

xrjf 230 Posting Whiz

Here is the next Mates8 version (8.4.2). I have tried to give more explanations but perhaps not so much as it would be convinient. So, I beg your pardon for this and for my lack of good english, although you may be sure I strive hard -or that's what I believe.
If you are interested in Mates8v8.4.2 you may take a look to the images here or download the .pdf tutorial (contents should be the same) and the .zip file of the source code.
b58000387eec862d0f89351d9c1e21eba4fcc9cfbd92d7ba4a82d1d4df7ace71707103716af8fd61e23bf50ed8c0f58dcf0c6da11157616f69084394f5b9a176df74e9a6e5401fad652186f426e2d812

xrjf 230 Posting Whiz

Well, drawing on the fly allows to customize instead of a static image.

xrjf 230 Posting Whiz

I hope you have put the code in order. Sorry, I'm perhaps a little late, but was busy.
Here is the timezoneinfo renamed as "myTimeZoneInfo" and a new class, that inherits from panel to draw from scratch a clock:
dc0d288c8cf756ce320f50d686c11cd2
...and the code:

xrjf 230 Posting Whiz

Well, my VStudio express does not bother for Timezoneinfo class, neither the project is version 2.0 nor 4.5. I think an easy workaround would be to rename TimeZoneInfo class in file TimeZoneInfo.vb to myTimeZoneInfo class or any other name you wish.

xrjf 230 Posting Whiz

Sorry, as you can see my english is not so good, specially when writing fast. I really meant I wait for your news or reply.

xrjf 230 Posting Whiz

Don't misunderstand me, please. I appreciate your efforts and wait to your news.
Best Regards.

xrjf 230 Posting Whiz

Really, don't you want to start a new thread? Anyway, thanks for the info, I'll take note. I've been developing till VS2010 with Pro version because time ago I had modified a "simple" USB device driver and needed to update for newer Windows. But it seems I will no longer need more updates and so that version.

xrjf 230 Posting Whiz

Right, TimeZoneInfo not supported in .NET versions <3.5. There is Here a class similar. I've added to the project and build for .NET v2.0. I have had a bit of problems to understand Time-Zone-Class and perhaps it was not necessary but I have added two methods:

    ''' <summary>
    ''' Returns a value indicating whether this time 
    ''' zone is within a daylight saving time period.
    ''' </summary>
    <DebuggerHidden()> _
    Public Shared Function IsDaylightSavingTime(dtUTC As DateTime, tzi As TimeZoneInfo) As Boolean
        Dim dUtcNow As DateTime = dtUTC.AddMinutes(-(tzi._tzi.bias))
        Dim sUtcNow As DateTime = dtUTC.AddMinutes(-(tzi._tzi.bias + tzi._tzi.daylightBias))
        Dim dt As DaylightTime
        Try
            If tzi._tzi.daylightDate.wMonth <= tzi._tzi.standardDate.wMonth Then
                'Daylight saving time starts and ends in the same year
                dt = tzi.GetDaylightChanges(dUtcNow.Year)
                If dt.Delta <> TimeSpan.Zero Then
                    If dUtcNow >= dt.Start AndAlso sUtcNow < dt.End Then
                        Return True
                    Else
                        'Return False
                    End If
                End If
            Else
                'Daylight saving time starts and ends in diferent years
                dt = tzi.GetDaylightChanges(sUtcNow.Year)
                If dt.Delta <> TimeSpan.Zero Then
                    If dUtcNow < dt.Start AndAlso sUtcNow >= dt.End Then
                        'Return False
                    Else
                        Return True
                    End If
                End If
            End If
        Catch ex As Exception
            Dim s As String = ex.Message
        End Try
        Return False
    End Function

and

    ''' <summary>
    ''' Returns the daylight saving time for a particular TimeZoneInfo and year.
    ''' </summary>
    ''' <param name="year">The year to which the daylight 
    ''' saving time period applies.</param>
    <DebuggerHidden()> _
    Public Function GetDaylightChanges( _
    ByVal year As Integer, tzInfo As TimeZoneInfo) As System.Globalization.DaylightTime
        Dim tzi As New …
xrjf 230 Posting Whiz

All the text data come from TimeZoneInfo.GetSystemTimeZones()(Click Here). My current language is set to "es-es", in your's text data will be in your current language.

xrjf 230 Posting Whiz

@pezza Those clock images look fine. I had a little taste managing timezones. Here is a screenshot:
4a76ae9329933032f9532f637c76a69b

xrjf 230 Posting Whiz

@rajeshmca03 Do you mean a Global Unique Identifier? If so, you may get a new Guid and just append a counter, for example like this:

Module Module1

    Sub Main()
        Try
            Dim sGuid As String = String.Empty
            Dim nOption As Int32 = 0
            Dim sequenceCount As Int32 = 0
            Dim curGlobalIdent As String = ""
            Dim formatLn As Int32 = 6
            Do
                Console.WriteLine("1. Get a new Guid.")
                Console.WriteLine("2. Increment by one.")
                Console.WriteLine("3. Exit.")
                Console.WriteLine("Enter the desired option number and press 'Enter':")
                Dim e1 As String = Console.ReadLine
                If Int32.TryParse(e1, nOption) Then
                    Select Case nOption
                        Case 0, 3 : Exit Do
                        Case 1
                            Dim g As New Guid
                            sGuid = g.ToString
                            curGlobalIdent = sGuid + "-" + StrDup(formatLn - 1, "0") + "1"
                            sequenceCount = 1
                            Console.WriteLine(curGlobalIdent)
                        Case 2
                            sequenceCount += 1
                            Dim sHex As String = Hex(sequenceCount)
                            If Len(sHex) < formatLn Then
                                sHex = StrDup(formatLn - Len(sHex), "0") + sHex
                            End If
                            curGlobalIdent = sGuid + "-" + sHex
                            Console.WriteLine(curGlobalIdent)
                    End Select
                End If
            Loop
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
            Console.WriteLine("Press 'Enter' to exit")
            Console.ReadLine()
        End Try

    End Sub
End Module
xrjf 230 Posting Whiz

The mentioned modifications.

xrjf 230 Posting Whiz

@cgeier: your code works like a charm. Just did some minor changes. For example, MainForm.getData is a function returning a datatable:

    Public Function getData(ByRef err As Exception) As DataTable
        ' This function configures and displays the label(s) for each team that is currently on-call.  It extracts the data from the SQL database in to a
        ' Data Reader so that the values of the person on-call for each team can be pulled in to each label.  The query pulls out the team, teammember and
        ' schedule details by querying the current date/time and examining who is on-call at that time for each team.
        Dim retDataTable As New DataTable
        Try
            Dim rowCount As Integer = 0

            'update status
            ToolStripStatusLabel1.Text = "Status: "

            'refresh the StatusStrip1
            'to ensure the ToolStripStatusLabel1
            'text is updated
            StatusStrip1.Refresh()


            ' Create SQL Connection and query using SQL Command based on Connection String

            Console.WriteLine("Connection String: " + SQLExpressDB.connectStr)


            Using cn As New SqlConnection(SQLExpressDB.connectStr)


                Dim sqlText As String = String.Empty
                sqlText = "SELECT Team.name as 'TeamName', TeamMember.firstName, "
                sqlText += "TeamMember.Surname, TeamMember.onCallPhone, TeamMember.location, "
                sqlText += "Schedule.start, Schedule.finish FROM Team "
                sqlText += "INNER JOIN TeamMember "
                sqlText += "ON Team.teamID = TeamMember.teamID "
                sqlText += "INNER JOIN Schedule "
                sqlText += "ON TeamMember.employeeID = Schedule.TeamMemberEmpID "
                sqlText += "WHERE (Schedule.start < { fn NOW() }) AND (Schedule.finish > { fn NOW() })"


                Try
                    ' Open Connection
                    cn.Open()
                    Using cmd As New SqlCommand(sqlText, cn)
                        Dim dA As New SqlDataAdapter(sqlText, cn)
                        Try
                            dA.Fill(retDataTable)
                        Catch ex1 As Exception
                            Throw …
xrjf 230 Posting Whiz

...and for "user instances" Click Here

xrjf 230 Posting Whiz

I am not 100% sure, but I think the connection string should look like this:

Data Source=.\SQLExpress;Integrated Security=true;
User Instance=true;AttachDBFilename=|DataDirectory|\InstanceDB.mdf;
Initial Catalog=InstanceDB;

You may also inspect connections strings yourself here

xrjf 230 Posting Whiz

Have you answered?: what kind of source database am I going to access? Is it a TextFile, MySql, Access, Excel, Sql Server, and so on? The answer will determine 1) what kind of library OleDb, SqlServer, ... to use and 2) what connection string should I use.

xrjf 230 Posting Whiz

Well, perhaps it does not make the difference, but:

    Public Function LoadLabels() As Int32
        Dim cn As New SqlClient.SqlConnection("your connection string")
        Dim cmd As New SqlClient.SqlCommand( _
            "SELECT db_Team.db_team_TeamName, db_TeamMember.db_teammember_FirstName, db_TeamMember.db_teammember_Surname, db_TeamMember.db_teammember_OnCallPhone, db_TeamMember.db_teammember_Location, db_Schedule.db_schedule_Start, db_Schedule.db_schedule_Finish FROM db_Team INNER JOIN db_TeamMember ON db_Team.db_team_ID = db_TeamMember.db_teammember_TeamID INNER JOIN db_Schedule ON db_TeamMember.db_teammember_ID = db_Schedule.db_schedule_TeamMemberID WHERE (db_Schedule.db_schedule_Start < { fn NOW() }) AND (db_Schedule.db_schedule_Finish > { fn NOW() })", cn)
        cmd.CommandType = CommandType.Text
        Dim da As New SqlClient.SqlDataAdapter(cmd)
        Dim results As New DataTable("Results")
        'results.Locale = Globalization.CultureInfo.CurrentCulture
        Try
            cn.Open()
            da.Fill(results)
            label_Error.Text = results.Rows.Count + " Rows Found."
            For i As Int32 = 0 To results.Rows.Count - 1
                Dim teamName As String = _
                    results.Rows(i).Item("db_team_TeamName").ToString()
                Dim teamMemberFirstName As String = _
                    results.Rows(i).Item(" teamMemberFirstName").ToString
                ' ....
                Dim lblTeam As New Label
                With lblTeam
                    '...
                    .Text = teamName + vbCrLf + _
                        teamMemberFirstName ' + ....
                    '...
                End With
            Next
        Catch ex As Exception
            ' Display any errors...   
            label_Error.Text = "ERROR: " + ex.Message
            da.Dispose()
        Finally
            cn.Close()
        End Try

    End Function
xrjf 230 Posting Whiz

I guess your timer is an instance of System.Windows.Forms.Timer. Then, add an label to the form, say "label_error", and modify the Timer.Tick event so:

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Try

            ' your code goes here

        Catch ex As Exception
            Timer1.Stop()
            label_Error.Text = ex.Message
        End Try
    End Sub
xrjf 230 Posting Whiz

Be careful, though, with threading and pop-up windows: is not a good practice.
Really, the thread should send a message, in case of error, to the main thread to be noticed.

xrjf 230 Posting Whiz

Well, a Try-Catch would allow, for example if there are any transactions to cancel.
Also, if the timer calls once the function without any problem and suppose that for some reason in a next call there is an error, what would happen? Suppose cn.open() fails, a exception would rise and you would get no more information out from the database (I guess the timer thread would probably stop): you would only see the initial data in the labels.
I think its a good practice to enclose in try-catch and always, but especially during debugging, pop-out and show any error.

xrjf 230 Posting Whiz

Finally, the other 3 classes are:

Public Class m8Response
    Public sExpression As String
    Public retDouble As Double
    Public rpn As RPN_Stack
    Public Overrides Function ToString() As String
        Return retDouble.ToString(MathGlobal8.us)
    End Function
End Class




Public Class msg8
    Inherits ApplicationException

    Dim eP As exprParser
    Dim msg As String
    Public Sub New()
    End Sub
    Public Sub New(exprP As exprParser)
        eP = exprP
    End Sub
    Private Function msgN(n As Int32) As String
        Dim e1 As String = String.Empty
        Try
            Select Case n
                Case 1 : e1 = "Empty expression."
                Case 2 : e1 = "Token sequence ""{0} {1}"" is not valid."
                Case 3 : e1 = "Ending token ""{0}"" is not valid."
                Case 4 : e1 = "Starting token is not valid."
                Case 5 : e1 = "n/a: the expression is incomplete/unintelligible."
                Case 6 : e1 = "n/a, token ""{0}"" is unknown/not allowed."
                Case 7 : e1 = "Argument out of bounds."
                Case 8 : e1 = "n/a: stack is empty."
                Case 9 : e1 = "n/a: missing one or more matching left parenthesis."
                Case 10 : e1 = "n/a: missing one or more matching right parenthesis."
            End Select
        Catch ex As Exception
            Throw ex
        End Try
        Return e1
    End Function
    Public ReadOnly Property num(ByVal i As Int32, ParamArray Arr() As Object) As Exception
        Get
            Try
                If i < 1 Then
                    msg = "n/a"
                ElseIf Arr IsNot Nothing Then
                    Dim e1 As String = msgN(i)
                    msg = String.Format(e1, Arr)
                Else
                    msg = msgN(i)
                End If
            Catch ex As Exception
                Throw ex
            End Try …
xrjf 230 Posting Whiz

"reNum" stands for a Regex instance defined in class MathGlobal8. The purpose of "reNum" is to parse a number out from input string:

Imports System.Reflection
Imports System.Text.RegularExpressions
Imports System.Runtime.Serialization

<Serializable()> _
Public Class MathGlobal8

    Public Shared us As New Globalization.CultureInfo("en-US")
    Public Shared sNum = "(?<num>(([0-9]{1,3},[0-9]{3}(?![0-9])|[0-9])+\.?[0-9]*|[0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?)"
    Public Shared reNum As New Regex(sNum)

    Shared Function NameAndVersion() As String
        Dim sNV As String = String.Empty
        Try
            Dim asmbly As Assembly = System.Reflection.Assembly.GetAssembly(GetType(MathGlobal8))
            Dim name As AssemblyName = asmbly.GetName()
            sNV = name.Version.ToString
            sNV = name.Name + " -- " + Left(sNV, Len(sNV) - 2)
        Catch ex As Exception

        End Try
        Return sNV
    End Function

End Class
xrjf 230 Posting Whiz

If you have understood the above "Module1" example, you'll also see that class exprParser follows similar mechanics: nextExpr() calls nextTerm() which, in turn, calls nextPow(), that calls nextToken(). Here, nextToken() grabs the next number and operator (unless it's the last token) before returning.

Imports System.Text.RegularExpressions
Imports System.Text

<Serializable()> _
Public Class exprParser

    Dim bGetRPN As Boolean
    Dim cnt As Int32
    Dim iRe, curOp As Int32
    Dim curNum As Double
    Dim sExpr As String
    Dim vByte() As Byte
    Dim ln As Int32
    Friend err As Exception
    Public ret As m8Response
    Dim rpn As RPN_Stack
    Dim mode As modeType
    Dim reNum As Regex = MathGlobal8.reNum
    Public Sub New(mode As modeType, Optional strToParse As String = "")
        Try
            InitStr(strToParse)
            Me.mode = mode
            Init()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Sub Init()
        Try
            ret = New m8Response
            If (mode And modeType.PrepareForEval) Then
                bGetRPN = True
            Else
                bGetRPN = False
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Sub InitStr(strToParse As String)
        Me.sExpr = strToParse
        vByte = Text.ASCIIEncoding.ASCII.GetBytes(sExpr)
        ln = vByte.Length
    End Sub
    Public Function Parse(strToParse As String, ByRef Result As Double) As Boolean
        Dim bRet As Boolean
        Try
            InitStr(strToParse)
            bRet = Parse(Result)
        Catch ex As Exception
            err = ex
            bRet = False
        End Try
        Return bRet
    End Function
    Public Function Parse(ByRef Result As Double) As Boolean
        Try

            cnt = 0 : iRe = 0 : curNum = 0.0 : err = Nothing

            If Not rpn.bInitialized Then
                rpn = New RPN_Stack(Me, ln * 3 / 2) …
xrjf 230 Posting Whiz

Present explanation is about version 8.4.1. There have been many changes, so the code is differs slightly from 8.4.0: I am sorry for the inconvients it may cause.
But, now, the code seems to me pretty fast, considering we are talking about VBasic. In a desktop (Pc @3GHz-64bits Windows 8.1) the average time for an expression like 1600/((1-(1+1/4)^30)/(1-(1+1/4))) it can take about 10/20 ns to process the arithmetic:
29039bd20b59281c29c45331ceb85121
Lets enumerate the classes. These are:
exprParser
m8Response
MathGlobal8
msg8
RPN_Stack

At the moment, a Mates8 client just needs to be employ exprParser and m8Response classes.
Imports Mates8

Public Class Form1
    Dim eP As exprParser
    Dim nIter As Int32 = 1000
    Const ticks_second = 10 ^ 7
    Const ms_second = 1000

#Region "Calculate"
    Sub Calculate()
        Try
            Dim t1 As Int64 = Now.Ticks
            Dim db As Double
            tbOutput.Text = ""
            lblStack.Text = ""

            eP = New exprParser(modeType.Calculate, tbInput.Text)

            For i = 1 To nIter
                If Not eP.Parse(db) Then
                    ' Show error message:
                    lblMessage.Text = eP.retErr.ToString
                    Exit Sub
                End If
            Next
            Dim t2 As Int64 = Now.Ticks - t1
            ' Show the result:
            tbOutput.Text = eP.ret.ToString
            lblMessage.Text = String.Format("exprParse.Parse()" + vbCrLf +               "Average Time: {0} ms " +
                   vbCrLf + "({1} iterations)", ((t2 / ticks_second / nIter _
                   ) * ms_second).ToString(MathGlobal8.us), nIter)
        Catch ex As Exception
            MessageBox.Show("Unexpected error:" + vbCrLf + ex.Message)
        End Try
    End Sub
#End Region

Evaluating the stack is much faster, once the stack has been …

xrjf 230 Posting Whiz

Yes, your code now looks much neater. Have you seen this thread before?

xrjf 230 Posting Whiz

Here is the explanation, along with a VB.Net module.
There are four consecutive functions. Each one invokes the next and, on exit, returns back to the previous function the result. Namely:
1. expression() performs "+" and "-" operations
2. term() performs "" and "/" operations
3. pow() performs "^","%" and "!" operations
function expression() calls term()
function term() calls pow()
function pow() calls token()
Then token() returns back the first operand, after setting the current caracter behind the operand, so pointing to the first operator. In case of a "+" or "-" operator (as in "2+3"), the execution will return back to expression, receiving the first operand value and then calling back to term() for the second operand. In a similar way, term() will call pow(), pow() will call token() and, then return, all the way up, to expression. There, operation "+" or "-" will take place.
In case there is another operator after the second operator, for instance a "
" in "2+34", in the middle of the way up, from token() to expression(), function term() will find that must perform current operator "". So before the addition, term() will call pow() asking for the second operand. This will be a "4", "3*4" will be calculated and return back to expression() his second operand equal to 12 and add to the first 2.
When token() founds a "(" calls, recursively, to expression(). Expression() will return back to token() the result …

xrjf 230 Posting Whiz

Why use labels? Why not a datagrid or simply a listbox or a multiline textbox?
BTW, why not enclose in a try-catch and use a name more meaningful as myvalue?
I would set one cmd.CommandText (1 connection) to:
"SELECT dbTeam.,db_TeamMember., db_Schedule.* " + _
"WHERE (db_Schedule.db_Schedule_Start < "+...+" finish > { fn NOW() }" +
"AND db_Schedule.db_schedule_TeamMemberID = db_TeamMember.db_teammember_ID"+
"AND db_Team.db_Team_ID = db_TeamMember.db_TeamMember_TeamID "
Maybe also add a sort to the CommandText?
Here on, continue with while (reader.Read()) ...

xrjf 230 Posting Whiz

I believe any code is valid, may be (why not?) old fashioned, if achieves the required tasks without errors, all the rest will need improvement. I am almost sure you are aware of Click Here and Click Here

xrjf 230 Posting Whiz

Instead of drawing the box, another approach would be to load 2 images: one with the box and the other without (or whatever images you decide). Then in the OnDrawItem() just call e.Graphics.DrawImage() method to draw the box image or the no-box-image.

xrjf 230 Posting Whiz

I see, in a short term, I'll provide Daniweb an extense explanation.

xrjf 230 Posting Whiz

Have you ever wanted to develop a math parser and evaluator? Are you in such a quandary or just have curiosity or interest in the matter? If so, you may download the complete source version 8.3.48 or later, but be warned there is almost no comment; or instead, follow versions v8.4.x which will be more digest and, of course, all the source code for each new v8.4.x will be there, if you wish, to download.
Currently, v8.4.0 does simple arithmetic but contains the main classes and algorithms that hold all the rest.
Version 8.4.0 has been developed entirely under MS Visual Studio Express 2013 for Windows Desktop and, surely, in future releases.
In the downloadable example you may find Form1 having 2 textboxes: tbInput and tbOuput, one button and a label to show eventual messages: btnCalculate and lblMessage.

When running, user types for example "3+4/2" (without quotes) in tbInput and clicks the "Calculate" button, so btnCalculate_Click() is executed and, in turn, the Calculate() method.
There, the shared method exprParser.Parse is called passing the input string as parameter.
If everything goes right, there will be no error, eP.retErr will be 'Nothing' and eP.retVal will have the result.
If not, eP.retErr.ToString contains the error message.
In the example, the ouput would be 5.
On the contrary, an incomplete "3+4/" would show the corresponding error message.
Note: simple arithmetic of only numbers and operators give the expected result, at the moment.

Public Class …
xrjf 230 Posting Whiz

For me works fine: in last line number 12. the instance of class EvalRunTime is created in variable "o".
You just need to add a method called "EvaluateItNonShared" in class EvalRunTime. In this manner in line 13. will be invoked properly as does in mine.
Here is the complete code (working):

Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection

Module Module1

    Sub Main()
        Compile("return 2+3", "")
    End Sub
    Public Sub Compile(ByVal vbCode As String, ByVal argsString As String)
        Dim oCodeProvider As VBCodeProvider = New VBCodeProvider
        Dim oCParams As CompilerParameters = New CompilerParameters
        Dim oCResults As CompilerResults
        Dim oAssy As System.Reflection.Assembly
        'Dim oType As Type


        Try
            ' Setup the Compiler Parameters  
            ' Add any referenced assemblies
            oCParams.ReferencedAssemblies.Add("system.dll")
            oCParams.ReferencedAssemblies.Add("system.xml.dll")
            oCParams.ReferencedAssemblies.Add("system.data.dll")
            oCParams.CompilerOptions = "/t:library"
            oCParams.GenerateInMemory = True

            ' Generate the Code Framework
            Dim sb As StringBuilder = New StringBuilder("")

            sb.Append("Imports System" & vbCrLf)
            sb.Append("Imports System.Xml" & vbCrLf)
            sb.Append("Imports System.Data" & vbCrLf)
            sb.Append("Imports System.Collections.Generic" & vbCrLf)
            sb.Append("Imports RBDS_Control.RBDS" & vbCrLf)

            ' Build a little wrapper code, with our passed in code in the middle 
            sb.Append("Namespace dValuate" & vbCrLf)
            sb.Append("Class EvalRunTime " & vbCrLf)
            sb.Append("Public Sub New()" & vbCrLf)
            sb.Append("End Sub " & vbCrLf)
            sb.Append("Public Shared Function EvaluateIt(" & argsString & ") As Object " & vbCrLf)
            sb.Append(vbCode & vbCrLf)
            sb.Append("End Function " & vbCrLf)
            sb.Append("Public Function EvaluateItNonShared(" & argsString & ") As Object " & vbCrLf)
            sb.Append(vbCode & vbCrLf)
            sb.Append("End Function " & vbCrLf)
            sb.Append("End Class " & vbCrLf)
            sb.Append("End Namespace" & vbCrLf)
            Debug.WriteLine(sb.ToString())

            Try
                ' Compile and get results 
                ' 2.0 Framework …
xrjf 230 Posting Whiz

Who knows when a security issue may overcome, but take a look at Click Here
Then, I think this other way may help:

                objConn = New OleDbConnection(sconn)
                objConn.Open()
                Dim AccessCommand As OleDb.OleDbCommand
                ' Set the sql string with 2 parameters:
                Dim sql As String = "UPDATE [NewItem] SET ITEM_STATUS=? WHERE ITEM_NO=?"
                AccessCommand = New OleDbCommand(sql)
                ' Fill in the parameters:
                Dim qParam(1) As OleDb.OleDbParameter
                qParam(0) = New OleDb.OleDbParameter("@ITEM_STATUS", OleDb.OleDbType.LongVarWChar)
                qParam(0).Value = "S"
                qParam(1) = New OleDb.OleDbParameter("@ITEM_NO", OleDb.OleDbType.LongVarWChar)
                qParam(1).Value = textbox1.text
        ' Add the parameters to the access command:
                For i = 0 To qParam.Length - 1
                    AccessCommand.Parameters.Add(qParam(i))
                Next
                ' Link the access cmd to the connection:
                AccessCommand.Connection = objConn
                Dim n As Int32 = AccessCommand.ExecuteNonQuery()
                objConn.Close()
                If n = 0 Then
                    ' err (No registers got updated)
        Else
            ' OK ('n' registers were updated)
        End If
xrjf 230 Posting Whiz

...of course:

 dim Konter as Int32
xrjf 230 Posting Whiz

I can't verify your code, but seems it should work iterating:

Konter = 1 ' intialize
Do While dReader.Read() 
    ' get in Kode a 3char string of Konter filled with zeros at the left, 
    ' prepended by "HS" ("HS001", "HS002", "HS003" and so on):
    Kode = String.Format("HS{0:000}", Konter)
    Konter += 1 ' increment Konter by one
loop
xrjf 230 Posting Whiz

Change the above to something like:

                If oCResults.Errors.Count <> 0 Then
                    Console.WriteLine(oCResults.Errors.Item(0).ToString)
                Else
                    ' No Errors On Compile, so continue to process...
                    oAssy = oCResults.CompiledAssembly
                    Dim vModules() As System.Reflection.Module = oAssy.GetModules()
                    For Each tI As TypeInfo In vModules(0).Assembly.DefinedTypes
                        If tI.Name = "EvalRunTime" Then
                            Dim mI As MethodInfo = tI.GetMethod("EvaluateIt")
                            Console.WriteLine(mI.Invoke(Nothing, Nothing).ToString) '--> 5
                            Dim myType As Type = tI.UnderlyingSystemType
                            Dim o As Object = Activator.CreateInstance(myType)
                            Console.WriteLine(o.EvaluateItNonShared().ToString) ' --> 5
                            Exit For
                        End If
                    Next
                End If
xrjf 230 Posting Whiz

The above code has been replaced by this new one.
Here, the points of discontinuity have been taken into account.
So, for example, function tan(x) does not joint adjacent points Yi>>0 and Yi+1<<0 with a line.

<%@ Page Language="vb" MasterPageFile="~/mates4.Master" AutoEventWireup="false" CodeBehind="graphic.aspx.vb" Inherits="mates4.graphic" %>

<asp:Content ID="Content5" ContentPlaceHolderID="head" runat="server">
        <style type="text/css" media="screen">
    .margin { margin-left: 10px; position:relative; top:0px;}
    .grPos { position:relative; left: 20px; top: 0px;}
    </style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="content2L" runat="server" Visible="false">
    <h3><asp:Label runat="server" >&nbsp;&nbsp;Function grapher</asp:Label></h3>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="scriptID" runat="server" Visible="false">
    <script type="text/javascript">
        if (document.getElementById)
            getElemById = function (id) {
                return document.getElementById(id);
            }

        else if (document.all)
            getElemById = function (id) {
                return document.all[id];
                // note that we use square brackets here
            }
        function coord(e, mi) {
            try {
                var Xm,Xb,Xmargin,Ym,Yb,Ymargin,Xmin;
                Xm = getElemById('<% = Xm.ClientID %>').value; Xm = parseFloat(Xm);
                Xb = getElemById('<% = Xb.ClientID%>').value; Xb = parseFloat(Xb);
                Xmargin = getElemById('<% = Xmargin.ClientID%>').value; Xmargin = parseFloat(Xmargin);
                Xmin = getElemById('<% = Xmin.ClientID%>').value; Xmin = parseFloat(Xmin);
                Ym = getElemById('<% = Ym.ClientID%>').value; Ym = parseFloat(Ym);
                Yb = getElemById('<% = Yb.ClientID%>').value; Yb = parseFloat(Yb);
                Ymargin = getElemById('<% = Ymargin.ClientID%>').value; Ymargin = parseFloat(Ymargin);
                var rct = mi.getBoundingClientRect();
                var x0 = e.clientX - rct.left - Xmargin;
                var y0 = e.clientY - rct.top - Ymargin;
                var oX = getElemById('<% =tbX.ClientID %>');
                var oY = getElemById('<% =tbY.ClientID%>');
                oX.value = Xm * x0 + Xb;
                oY.value = -Ym * y0 + Yb;
                var str = '' + oX.value;
                var pos = str.indexOf('.');
                if(pos>-1 && str.length - pos>2 && Math.abs(oX.value)>1)
                { oX.value = Math.round(oX.value * 1000 + 0.005) …
xrjf 230 Posting Whiz

sorry for the index mistakes, let me retry: ...then a new point, say (h,f(h)), must be drawn between point (xi,yi) and (x(i+1),y(i+1)) because xi<h<x(i+1). Redrawing problem is, now, to repaint rectangle((xi,ymax);(xi+1,ymin)), where ymax=max{yi,f(h),yi+1} ymin=min{yi,f(h),yi+1}. This, if points are joined by lines; if not, depending, more points should be considered, for ex. rectangle((xi-1,ymax);(xi+2,ymin) and ymax=max{yi-1,yi,f(h),yi+1,yi+2} ymin=min{yi-1,yi,f(h),yi+1,y+2} in case of a cuadratic interpolation.

xrjf 230 Posting Whiz

Suppose code Click Here was adopted for a window's panel control. Suppose again, in a given instant the panel has drawn points (x0,y0) (x1,y1)... (xi,yi) ...,(xn,yn) and then a new point, say (h,f(h)), must be drawn between point (xi,yi) and (x(i+1),y(i+1)) because xi<h<x(i+1). Redrawing problem is, now, to repaint rectangle((xi-1,ymax);(xi+1,ymin)), where ymax=max{yi-1,f(h),yi+1} ymin=min{yi-1,f(h),yi+1}. This, if points are joined by lines; if not, depending, more points should be considered, for ex. rectangle((xi-2,ymax);(xi+2,ymin) and ymax=max{yi-2,yi-1,f(h),yi+1,y+2} ymin=min{yi-2,yi-1,f(h),yi+1,y+2} in case of a cuadratic interpolation.

xrjf 230 Posting Whiz

Converting method 'EvaluateIt' to 'shared'

Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection

Module Module1


    Sub Main()
        Compile("return 2+3", "")
    End Sub
    Public Sub Compile(ByVal vbCode As String, ByVal argsString As String)
        Dim oCodeProvider As VBCodeProvider = New VBCodeProvider
        Dim oCParams As CompilerParameters = New CompilerParameters
        Dim oCResults As CompilerResults
        Dim oAssy As System.Reflection.Assembly
        'Dim oType As Type


        Try
            ' Setup the Compiler Parameters  
            ' Add any referenced assemblies
            oCParams.ReferencedAssemblies.Add("system.dll")
            oCParams.ReferencedAssemblies.Add("system.xml.dll")
            oCParams.ReferencedAssemblies.Add("system.data.dll")
            oCParams.CompilerOptions = "/t:library"
            oCParams.GenerateInMemory = True

            ' Generate the Code Framework
            Dim sb As StringBuilder = New StringBuilder("")

            sb.Append("Imports System" & vbCrLf)
            sb.Append("Imports System.Xml" & vbCrLf)
            sb.Append("Imports System.Data" & vbCrLf)
            sb.Append("Imports System.Collections.Generic" & vbCrLf)
            sb.Append("Imports RBDS_Control.RBDS" & vbCrLf)

            ' Build a little wrapper code, with our passed in code in the middle 
            sb.Append("Namespace dValuate" & vbCrLf)
            sb.Append("Class EvalRunTime " & vbCrLf)
            sb.Append("Public shared Function EvaluateIt(" & argsString & ") As Object " & vbCrLf)
            sb.Append(vbCode & vbCrLf)
            sb.Append("End Function " & vbCrLf)
            sb.Append("End Class " & vbCrLf)
            sb.Append("End Namespace" & vbCrLf)
            Debug.WriteLine(sb.ToString())

            Try
                ' Compile and get results 
                ' 2.0 Framework - Method called from Code Provider
                oCResults = oCodeProvider.CompileAssemblyFromSource(oCParams, sb.ToString)
                ' 1.1 Framework - Method called from CodeCompiler Interface
                ' cr = oICCompiler.CompileAssemblyFromSource (cp, sb.ToString)


                ' Check for compile time errors 
                If oCResults.Errors.Count <> 0 Then
                    Console.WriteLine(oCResults.Errors.Item(0).ToString)
                Else
                    ' No Errors On Compile, so continue to process...
                    oAssy = oCResults.CompiledAssembly
                    Dim vModules() As System.Reflection.Module = oAssy.GetModules()
                    For Each tI As TypeInfo In vModules(0).Assembly.DefinedTypes
                        If tI.Name = "EvalRunTime" Then
                            Dim mI As MethodInfo = tI.GetMethod("EvaluateIt")
                            Console.WriteLine(mI.Invoke(Nothing, Nothing))' console output= …
xrjf 230 Posting Whiz

You may find the answer by inspecting in which programming language do you feel more confortable. Maybe it's no so important the language choice -most languages are sufficiently empowered-, but with which may you strive better to succeed.

xrjf 230 Posting Whiz

By means of Mates8, graph coding becomes a bit easier.
The web page has four textboxes so the figure gets bounded to the left, right, top and bottom; and a draw button.
Additionally, a panel control will contain the image generated by the code after the button is pressed.

xrjf 230 Posting Whiz

I'm not very sure if a PictureBox is best, depending perhaps a Panel control would do. I also think that the graph's background (axis, axis divisions, text and so on) may persist in a bitmap and employ a Graphics instance gr = Graphics.FromImage(bmp) to draw the rest.

xrjf 230 Posting Whiz

Search for "HttpWebRequest asyncronously" or Click Here