xrjf 230 Posting Whiz

If WebBrowser1_DocumentCompleted is leaved out like it was initially the other way round is to add an instruction if (map) return; at the start of Initialize() because for some reason looks like the javascript is modified, which makes the DocumentCompleted to be called again, which again invokes Initialize() and so in an infinit loop.

        function Initialize(zoomLevel,lat,lng,type){  
            //Get the type of map to start.
            //Need to convert the GoogleMapType enum
            //to an actual Google Map Type

            if(map) return;
            var MapType;

            switch (type)
            {
            // .... 
xrjf 230 Posting Whiz

I meant to fire only one time InvokeScript(), because DocumentCompleted can be invoked multiple times Click Here

xrjf 230 Posting Whiz

Try a static variable so DocumentCompleted fires just once (I had the same problem):

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
        'Initialize the google map with the initial settings.'
        'The Initialize script function takes four parameters'
        'zoom, lat, lng, maptype.  Call the script passing the'
        'parameters in.'
        Static bInit As Boolean = False
        If bInit Then Exit Sub
        WebBrowser1.Document.InvokeScript("Initialize", New Object() {InitialZoom, InitialLatitude, InitialLongitude, CInt(InitialMapType)})
        bInit = True
    End Sub
xrjf 230 Posting Whiz

Seems as there are 3 factors: a 'n' or 'y' value; extra_days or not; and procesDate (<,> or =) versus thisDate.
I would suggest to you to draw a table like this one and fill in all the different possibilities. At least having a clear method to follow it'll be easier and less error prone.

  Factors:

'n'/'y'.............:............'n'......................|........'y'
procDate vs.thisDate:      <      |      =      |    >    |

extra_Days..........:  = 0 | <>0  | =0   |<>0   | = 0|<>0 |
=================================================================

Actions to take:
ForeColor...........:      |      |Red   |Red   | 

BackColor...........:yellow|yellow|yellow|yellow|
Bold................:      |      | Yes  | Yes  |

Italic..............:      |  Yes |      | Yes  |
Strike..............:
xrjf 230 Posting Whiz

But it seems to me more appropiate perhaps to have a composite control, i.e., a custom control -for example a menu- containing other windows forms controls (Click Here)

xrjf 230 Posting Whiz

If the buttons are in the class file ctrlAddSitesMenu:

Imports System.Windows.Forms
Imports System.Windows.Forms.Control

Public Class ctrlAddSitesMenu

    Dim frm As Form
    'Declares Buttons for Opening Websites
    Dim OpenTraker As New Button
    Dim OpenDynamics As New Button
    Dim OpenInetPortal As New Button
    Dim OpenFrontPortal As New Button
    Dim OpenLoopcare As New Button
    Dim OpenViryNet As New Button
    Dim OpenSmpl As New Button
    Dim OpenFosWiki As New Button
    Dim OpenLola As New Button

    'Declare Button Constant Varibles
    Dim LocX As Integer = 0
    Dim LocY As Integer = 20
    Dim Row As Integer = 25
    Dim H As Integer = 25
    Dim W As Integer = 115

    Public Sub LoadButtons()

        'Declares attributes for Invidual buttons '
        'Declares Button names'
        OpenTraker.Name = "btnOpenTracker"
        OpenDynamics.Name = "btnOpenDynamics"
        OpenInetPortal.Name = "btnInetPortal"
        OpenFrontPortal.Name = "btnFrontPortal"
        OpenLoopcare.Name = "btnOpenLoopcare"
        OpenViryNet.Name = "btnOpenVirynet"
        OpenSmpl.Name = "btnOpenSimple"
        OpenFosWiki.Name = "btnOpenFosWiki"
        OpenLola.Name = "btnOpenLola"

        'Declares Button text'
        OpenTraker.Text = "Tracker"
        OpenDynamics.Text = "Dynamics"
        OpenInetPortal.Text = "Internet Portal"
        OpenFrontPortal.Text = "Frontier Portal"
        OpenLoopcare.Text = "Loopcare"
        OpenViryNet.Text = "Virynet"
        OpenSmpl.Text = "SIMPL"
        OpenFosWiki.Text = "FosWiki"
        OpenLola.Text = "Lola"

        'Declares Button Size'
        OpenTraker.Size = New Size(W, H)
        OpenDynamics.Size = New Size(W, H)
        OpenInetPortal.Size = New Size(W, H)
        OpenFrontPortal.Size = New Size(W, H)
        OpenLoopcare.Size = New Size(W, H)
        OpenViryNet.Size = New Size(W, H)
        OpenSmpl.Size = New Size(W, H)
        OpenFosWiki.Size = New Size(W, H)
        OpenLola.Size = New Size(W, H)

    End Sub
    Public Sub New(frm As Form)
        Me.frm = frm
        Try
            'Adds Button Click Handlers'
            AddHandler OpenTraker.Click, AddressOf OpenTrackerClick
            AddHandler OpenDynamics.Click, AddressOf OpenDynamicsClick
            AddHandler OpenInetPortal.Click, AddressOf OpenInetPortalClick …
xrjf 230 Posting Whiz

That's not possible with ClickOnce, it always installs in the application cache. You should use MSI or some other installer technology.

xrjf 230 Posting Whiz

I'm a newbie for sql server, but I did the installation yesterday. After several errors from a .net application another pc in the home group, a list box is populated. The listbox data is retrieved from a sql server database.
I had to configure windows firewall advanced settings to let sqlserver.exe pass through Click Here .
I dissabled sql server express services and enabled sql server services, sql server browser (not sure if this last one is necesary) and protocols (Click Here)
Lastly, I remember to enable both windows and sql server authentications (https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/change-server-authentication-mode).
So, after all that the connection string became for me:
Server=servername;Database=myDataBase;User Id=sa;Password=password;
and voila!

JamesCherrill commented: Relevant and really helpfu. Excellent contribution.l +15
xrjf 230 Posting Whiz

The color you are using is coincident or very similar to the one of the border color when the focus is on the control. When there are more than one control just one has the focus. Please, take a look to Click Here

xrjf 230 Posting Whiz

Why not host Asp.Net pages on the server and call them from vb.net through a username and password. Seems to me this question should be asked in Programming/Web development.

xrjf 230 Posting Whiz

More concisely, we may write:

    Private Sub tbID_TextChanged(sender As System.Object, e As System.EventArgs) Handles tbID.TextChanged
        Try
            Dim ID1 As Int32 = Int32.Parse(tbID.Text)
            Dim query = From row As DataRow In tbl.Rows Where row.Item("ID") = ID1
            tbName.Text = query(0).Item("Name")
        Catch ex As Exception
            tbName.Text = "Please, enter a valid ID."
        End Try
    End Sub
xrjf 230 Posting Whiz

I've felt free to modify a bit your code to what I thought was required:

Imports System.Data
Imports System.Data.OleDb
Imports System.Linq

Public Class TableDescription

    Dim conn As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim tblName As String = "Contacts"
    Dim tbl As DataTable
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ConnectToAccess()
    End Sub
    Public Sub ConnectToAccess()
        Dim conn As OleDbConnection = Nothing
        Try
            conn = New OleDbConnection
            conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
            "Data Source=C:\Users\Public\database1.accdb;" _
            + "Persist Security Info=False;"
            Try
                conn.Open()
            Catch ex As Exception
                MessageBox.Show("Failed to connect to data source")
            End Try
            Dim SqlQuery As String = "SELECT * FROM " + tblName
            Dim datblcontact As OleDb.OleDbDataAdapter
            datblcontact = New OleDb.OleDbDataAdapter(SqlQuery, conn)
            datblcontact.Fill(ds, tblName)
            Me.ListBox1.DataSource = ds.Tables(tblName)
            Me.ListBox1.DisplayMember = "Name"
            ' save the dataset's ds.table(0):
            tbl = ds.Tables(tblName)
        Catch ex As Exception
        Finally
            If conn IsNot Nothing Then
                conn.Close()
            End If
        End Try
    End Sub

    Private Sub tbID_TextChanged(sender As System.Object, e As System.EventArgs) Handles tbID.TextChanged
        Try
            Dim ID1 As Int32 = Int32.Parse(tbID.Text)
            ' select from the saved table 'tbl' those
            ' row(s) whose row.ID = ID1. Furthermore, select
            ' the field 'name': '
            Dim query = tbl.AsEnumerable().Select( _
                Function(row As DataRow) New With
                { _
                    .ID = ID1, _
                    .Name = row.Field(Of String)("Name") _
                })
            Dim IDrow = query(0) ' first selection row '
            ' assign the field 'name' from the first select row: '
            tbName.Text = IDrow.Name
        Catch ex As Exception
            tbName.Text = "Please, enter a valid ID."
        End Try
    End Sub
End …
xrjf 230 Posting Whiz

BTW this seems a question to ask in Programming/web development.

xrjf 230 Posting Whiz

By completed a database in vb.net, do you mean completed in Asp.Net? If that's not the case, first complete all the tables updates and so forth in Asp.Net. Then search the web for "web hosting with access database" to host your access database and the complete application in the Internet.

xrjf 230 Posting Whiz

Below lines #32 and #72 you could add these two snippets in order to remember if the checkbox is checked or not.

                If InStr(sType, ".button") Then
                    bf.Serialize(fs, "")
                ElseIf InStr(sType, ".checkbox") Then
                    bf.Serialize(fs, CType(ctr, CheckBox).Checked.ToString)
                ElseIf InStr(sType, ".label") Then
                    bf.Serialize(fs, "")
                End If

                Dim checked As String = bf.Deserialize(fs)
                If InStr(sType, ".checkbox") Then
                    If checked = "True" Then
                        CType(ctr, CheckBox).Checked = True
                    Else
                        CType(ctr, CheckBox).Checked = False
                    End If
                End If
xrjf 230 Posting Whiz

deserialize1.PNG deserialize2.PNG
The following code may be a poor solution, but as far as I know controls are not serializable unless having a custom serializable class for each type of control. This is a workaround. Another possibility could be to get properties through Reflexion, but again gaining complexity.

Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary

Public Class _De_Serialize

    Dim filePath As String = "C:\Users\Public\controls.dat"
    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
        Dim fs As FileStream = Nothing
        Try
            fs = New FileStream(filePath, FileMode.OpenOrCreate)
            Dim bf As New BinaryFormatter
            Dim cnt As Int32 = 0
            Dim vCtl(-1) As Control
            For Each ctr In Me.Controls
                ' ctls. having a numeric tag will be saved:'
                If IsNumeric(ctr.tag) Then
                    ReDim Preserve vCtl(cnt)
                    vCtl(cnt) = ctr
                    cnt += 1
                End If
            Next
            bf.Serialize(fs, cnt.ToString) ' save how many '
            For i = 0 To cnt - 1
                Dim ctr As Control = vCtl(i) ' next control to save'
                Dim sType As String = LCase(ctr.GetType.ToString)
                bf.Serialize(fs, sType)
                bf.Serialize(fs, ctr.Name.ToString)
                bf.Serialize(fs, ctr.Text)
                bf.Serialize(fs, ctr.Location.X.ToString)
                bf.Serialize(fs, ctr.Location.Y.ToString)
                '...eventually save more properties '
                Me.Controls.Remove(ctr)
            Next
        Catch ex As Exception
        Finally
            If fs IsNot Nothing Then
                fs.Close()
            End If
        End Try
    End Sub
    Private Sub btnRestore_Click(sender As System.Object, e As System.EventArgs) Handles btnRestore.Click
        Dim fs As FileStream = Nothing
        Try
            If Not IO.File.Exists(filePath) Then
                Exit Sub
            End If
            fs = New FileStream(filePath, FileMode.OpenOrCreate)
            Dim bf As New BinaryFormatter
            ' Get how many controls were saved: '
            Dim cnt …
xrjf 230 Posting Whiz

Before line #26 define int lastNum = (max+min)/2 for example. Then, substitute lines #29 to #32 by:

     if (strTemp == "NaN")
         temp = lastNum;
     else {
         temp = atoi(strTemp.c_str());    
         lastNum = temp;
     }
xrjf 230 Posting Whiz

I wonder why your line #15 isn't wrap like line #7 with If Not IsDBNull... because in case ...cells(4).value is DBNull because of an empty input, an exception will occur.

rproffitt commented: Nulls are small slug-like creatures of limited intelligence who drain energy. +12
xrjf 230 Posting Whiz

Of course in line 4. it should say -1 instead of -2.

xrjf 230 Posting Whiz

If, for example, you add the unordered list of names to listbox1, then you may transfer name by name to listbox2 just making sure before inserting you leave above the inserting index all names 'less than' the current one:

            For i As Int32 = 0 To ListBox1.Items.Count - 1
                Dim curr As String = ListBox1.Items(i)
                Dim j As Int32 = 0
                For j = 0 To ListBox2.Items.Count - 2
                    If curr < ListBox2.Items(j) Then Exit For
                Next
                ListBox2.Items.Insert(j, curr)
            Next
xrjf 230 Posting Whiz

See if this works. Panel1 that has two controls: a label and a picturebox with an image; and Panel2 is on top of Panel1 and hidding it. Besides, form "HiddenPanel" has 2 buttons to show hidden panel1 contents in panel2, and to clear panel2.

Imports System.Drawing.Imaging

Public Class HiddenPanel
    Function getPanelsBitmap(pnl As Panel) As Bitmap
        Dim bmp As New Bitmap(pnl.Height, pnl.Width)
        Try
            Dim vCtrl(-1) As Control, iv As Int32
            Dim vZ(-1) As Int32
            For Each ctr As Control In pnl.Controls
                ReDim Preserve vCtrl(iv), vZ(iv)
                vCtrl(iv) = ctr
                ' save the control's z-index:
                vZ(iv) = ctr.Parent.Controls.GetChildIndex(ctr)
                iv += 1
            Next
            ' sort controls by it's z-index:

            Array.Sort(vZ, vCtrl)
            Array.Reverse(vCtrl)

            Dim gr As Graphics = Graphics.FromImage(bmp)
            For Each ctr In vCtrl
                Dim img As New Bitmap(ctr.Width, ctr.Height)
                ctr.DrawToBitmap(img, New Rectangle( _
                    0, 0, ctr.Width, ctr.Height))
                gr.DrawImage(img, ctr.Location)
            Next
            gr.Dispose()
        Catch ex As Exception
            Throw ex
        End Try
        Return bmp
    End Function

    Private Sub btnShow_Click(sender As System.Object, e As System.EventArgs) Handles btnShow.Click
        Try
            ' picturebox2 is contained in panel2 on top and hidding panel1:
            '
            PictureBox2.Image = getPanelsBitmap(Panel1)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnClear_Click(sender As System.Object, e As System.EventArgs) Handles btnClear.Click
        PictureBox2.Image = Nothing
    End Sub
End Class
xrjf 230 Posting Whiz

I appreciate your translation and interest. As I previously pointed, actually have no time left for programming. Heaven thanks, I have seen your message left here time ago. If and when possible, I'll try to fix the website's form and then give notice here: in this manner, you -and anyone else in need of- may explain as much as pleases.

xrjf 230 Posting Whiz

Please excuse me, since it's been a long while since last time I came to this page and today I read your comment for the first time.
Lately, I have a lack of time to spend programming and that's the reason why there haven't been any improvements during months in Mates8, for example. I'm not very sure what do you mean by «...comment you some suggestions to improve MATES...»
If it's refering to Mates8 calculator, please, address yourself, in English, Spanish or Catalan, whatever you are most fond for.
http://xrjunque.nom.es/commentfrm.aspx
If the sentence refers to the current article, please, expose right here any comment or suggestion. The same stands if you're aiming to improve my level of mathematics knowledge.
Best regards.

xrjf 230 Posting Whiz

In order to improve the messages, lines 171 through 174:

 If max = min Then
   lblMessage.Text = "n/a: top and bottom values can't be equal or void."
   Throw New Exception(lblMessage.Text)
 End If

may be replaced by:

            If max = min Then
                If vDbl(2) = vDbl(3) Then
                    lblMessage.Text = "n/a: top and bottom values can't be equal or void."
                Else
                    lblMessage.Text = iComplexPts.ToString + " complex points couldn't be drawn."
                End If
                Throw New Exception(lblMessage.Text)
            End If

Also, depending on the criteria one follows for functions having complex values, lines 455-476:

              cjo = expr.eval_1var_DblToCjo(x + x1)
              If cjo IsNot Nothing Then
                  If cjo.pIm.IsZero Then
                       y = cjo.pRe.ToDouble
                  Else
                       bExclude = True
                       iComplexPts += 1
                  End If
              Else
                  bExclude = True
              End If

may be replaced by:

                        cjo = expr.eval_1var_DblToCjo(x + x1)
                        If cjo IsNot Nothing Then
                            y = cjo.pRe.ToDouble
                            Dim dbIm As Double = cjo.pIm.ToDouble
                            If (Not cjo.pRe.IsZero AndAlso _
                            Math.Abs(cjo.pIm.ToDouble / cjo.pRe.ToDouble) > 10 ^ -8) OrElse _
                           (cjo.pRe.IsZero AndAlso Not cjo.pIm.IsZero) Then
                                bExclude = True
                                iComplexPts += 1
                            End If
                        Else
                            bExclude = True
                        End If
xrjf 230 Posting Whiz

If you're looking for concision, you may code something like:

        static void Main(string[] args)
        {
            string str = "abc,123.xyz;praise;end,file,clear";
            Console.WriteLine(String.Join("\r\n", 
                Regex.Split(str, @"(\,|\.|\;)+")));
            Console.ReadLine();
        }
ddanbe commented: Hey, nice tip! +15
xrjf 230 Posting Whiz

Well, there is a solution consisting in examing the destiny's folder size while the backgroundworker thread is executing. Attached is a sample. Uses a thread instance, instead, but to the case makes no difference. The main process enters a loop which ends when all the source files have been copied, i.e., destination size >= source files size. Meanwhile, gets the destination size and updates the progress bar:

    Private Sub btnCopy_Click(sender As Object, e As EventArgs) Handles btnCopy.Click
        Try
            Me.enableDisBtns(False)
            If Me.nFase = 0 Then
                MsgBox("First click button to create files.")
                Exit Sub
            End If
            Me.enableDisBtns(False)
            totalSrcSize = getSrcSize()
            Dim t As New Thread(AddressOf cpyFiles)
            t.Start()
            Dim totalDstSize As Long = getDirSize(dstPath)
            Do While totalDstSize < totalSrcSize
                DspProgBar(CInt(totalDstSize * 100 / totalSrcSize)) ' dsp progress
                Application.DoEvents()
                totalDstSize = getDirSize(dstPath)
            Loop
            DspProgBar(CInt(totalDstSize * 100 / totalSrcSize))
            MsgBox("Copy has ended.")
            Me.nFase = 0
            DspProgBar(0)
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            Me.enableDisBtns(True)
        End Try
    End Sub
xrjf 230 Posting Whiz

Lets put down an example. If total size to copy, S, is 100 MegaBytes:
S= 100 M
Estimated speed, e, is 5 Megabytes per second:
e= 5M/s
When the elapsed time, t, is 1 second, copied % will be:
% = 1 second x 5M/s / 100 M x 100 = 5%
At t=5seconds:
% = 5 seconds x 5M/s / 100M x 100 = 25%
At t=20 seconds:
% = 20 seconds x 5M/s / 100M x 100 = 100%
If there is no mistake and assuming transfer rate is 5M/s, in 20 seconds the progress bar would be at 100%. I think its very clear that the estimation will always be an approximation and varies along time and from one machine to another.

xrjf 230 Posting Whiz

To be exact, KB and seconds are units, but the units must be coherent, of course. % = [size] x [T]/[size] x [T]
wiki

xrjf 230 Posting Whiz

Sorry, the % should be:
% = size_to_copy x (1/e) x time_elapsed / 100
[in dimensions: %(dimensionless) = (KB) x (seconds/KB) x (seconds) ]

xrjf 230 Posting Whiz

I was wandering if, maybe, first a total size of the files to be copied could be obtained. Then, we could make an estimation e= Kb copied/second and, why not?, the main thread could show the progress bar, for example, each second a rate:
time elapsed (seconds) / e

xrjf 230 Posting Whiz

Please, go to my website's download page Here. If needed, I'll appreciate any feedback. Hope it helps!

xrjf 230 Posting Whiz

Ops! I am sorry and thanks for your advice. Seems the file size exceeded the maximum. I hope this time it works.

xrjf 230 Posting Whiz

If ever you change your mind and go for the open source solution find attached a VStudio 2010 project. Need to say I did no charting. The .vb file names ending in "pdf" invoke pdfsharp.dll. The ones ending in "xls" correspond to the "pdf" ones with same sufix and the output format is an Excel Workbook. Note there are two font files (.ttf) to ensure the .pdf file contains embedded the required font. If you do so, you'll need to change the paths, the web reference, fields and anything else required to your needs.

savedlema commented: Thanks xrj, but I sorry, I can't see any attachment. Did you forget to attach? +2
xrjf 230 Posting Whiz

Why not use try-catch to trap and visualize errors, at least during test sessions? Once you can see the error message, the fix, almost always, will be more affordable. BTW, there is little difficulty to modify the query string by the user. See here and here.

xrjf 230 Posting Whiz

It depends, from my point of view and experience, on your taste and skills. I did an accounting project which employed Crystal Reports. Reading a good book or tutorial for Crystal Reports will save you many hours. The big advantage is that adding fields or totals in a report is easy and WYSIWYG, although I personally had some trouble during ClickOnce deployments. But after several tries all went smooth. Usually, new updates also reported new problems. The same as when upgrading Visual Studio or when having a new PC. Time after, as new reports were needed, I opted for PdfSharp -an Open Source Library-. All the previous problems dissapeared, but instead there was no WYSIWYG, so you I had to parametrize the fields, do subtotals, totals, page breaks and so on by code. This may be a hard task for some not used to this kind of work.

savedlema commented: Thanks very much xrj. +2
xrjf 230 Posting Whiz

Well, I think I see. Actually, it's none of my business to evaluate the work of
others, just to do my work, though one should not be blind, of course.

xrjf 230 Posting Whiz

Before getting variables into play, why not consider parentheses? As a hint, a parser could look into the most inner parentheses, calculate the enclosed expression and then focus on the next more outer parentheses. In order to calculate each enclosed parentheses expression, first one could look for ^operators, then /operators and so on. I did try something similar -but without dictionaries instances- and it's not a simple task. The most confusing was that during the coding and testing, more and more obstacles appeared.

xrjf 230 Posting Whiz

Long time ago, by means of Bussiness Basic, I had this problem as "homework". It did was a headache and there was no Wikipedia nor Internet, just some colleagues comments that really did their best. Allow me to contribute with the following code:

        static void Main(string[] args)
        {
           System.Globalization.CultureInfo ci = 
               new System.Globalization.CultureInfo("en-US");
           System.Globalization.CultureInfo.DefaultThreadCurrentCulture = 
               ci;
           Int32 initYear = 1990;
           Int32 curYear = initYear;
           DateTime dt = new DateTime(curYear, 1, 1);
           DateTime dtStop = DateTime.Today;
           Int32 nErr1, nErr2, nDates;
            Int32 code0, code1, code2;
            do
            {
                Console.Write(dt.ToString("yyyy/MM/dd"));
                code0 = (Int32)dt.DayOfWeek;
                code1 = dateDaycode(dt.Year, dt.Month, dt.Day);
                if (code0 != code1)
                    nErr1++;
                code2 = dateDaycodeWiki(dt.Year, dt.Month, dt.Day);
                if (code0 != code2)
                    nErr2++;
                Console.WriteLine();
                dt = dt.AddDays(1);
                if (dt.Year != curYear)
                {
                    curYear++;
                    dt = new DateTime(curYear, 1, 1);
                }
                nDates++;
            } while (dt <= dtStop);
            if (nErr1 != 0)
                Console.WriteLine(nErr1.ToString() + " code 1 errors found ");
            if (nErr2 != 0)
                Console.WriteLine(nErr2.ToString() + " code 2 errors found ");
                   Console.WriteLine(nDates.ToString() + " total days between dates 01/01/" + 
                   initYear.ToString() + " and " + dtStop.ToShortDateString());
           Console.WriteLine("Press Enter to exit");
           Console.ReadLine();

        }
        public int dateDaycode(int year, int month, int day)
        {
            //Using Zeller's formula
            int d1, d2, d3, d4, code;
            if (month == 1)
            {
                month = 13; year--;
            }
            if (month == 2)
            {
                month = 14; year--;
            }
            d1 = year / 4;
            d2 = year / 100;
            d3 = year / 400;
            d4 = day + 2 * month + 3 * (month + 1) / 5 + year; …
ddanbe commented: Allow me to upvote, albeit a bit late I guess. :) +15
xrjf 230 Posting Whiz

In a recent fix Line #137 has been replaced by:

            If Me.chkAutoTopBottom.Checked Then
                max = max2 : min = min2
            Else
                max = vDbl(2) : min = vDbl(3)
            End If

and, in mouseEventInit() method - line #226 -, Ymargin.value by:

            Ymargin.Value = ((marginPt0.Y + marginPt1.Y) / 2.0 * bmpH / h).ToString(MathGlobal8.us)
xrjf 230 Posting Whiz

This snippet code is the responsible to obtain the determinant, cofactor, adjoint and inverse matrix. A expression class instance may hold a number, polynomial or any expression like, for example, 'sin(x)' in an AST tree. A exprMatrix class is nothing else than a matrix where the entries are expression class instances. The complete code is downloadable here

    Public Function opDeterminant( _
                Optional bGetInverseOrCofactorMtx As Boolean = False, _
                Optional ByRef InvMtx As ExprMatrix = Nothing, _
                Optional ByRef cofactorMtx As ExprMatrix = Nothing, _
                Optional ByRef adjoint As ExprMatrix = Nothing) As Expression
        Dim vTable()() As Int32 = { _
            New Int32() {1, 2, 3}, _
            New Int32() {3, 1, 3, 1}, _
            New Int32() {3, 4, 3, 2, 3}, _
            New Int32() {5, 3, 1, 5, 3, 1}, _
            New Int32() {5, 2, 7, 2, 1, 2, 3}, _
            New Int32() {7, 1, 5, 5, 3, 3, 7, 1}, _
            New Int32() {7, 8, 1, 6, 5, 4, 9, 2, 3}, _
            New Int32() {9, 7, 5, 3, 1, 9, 7, 5, 3, 1}, _
            New Int32() {9, 6, 3, 10, 9, 4, 3, 8, 9, 2, 3}}
        Dim retDetermExpr As Expression = Nothing
        Dim i, j As Int32
        Dim N As Int32 = Me.Rows
        Dim vIndex(N) As Int32
        Dim c As Int32 = 0
        Dim aux, iAux, viAux(N) As Int32
        Dim fact As Int32 = N
        Dim cI(N - 1), cInv(N - 1) As Int32
        Try
            ' See http://en.wikipedia.org/wiki/Heap's_algorithm
            ' and also …
xrjf 230 Posting Whiz

Really, there was no error but because of the way I programmed Gauss-Jordan method the polynomial degrees of the matrix's entries increased in excess. By finding the G.C.D., if any, the degree may be reduced. Anyway, as can see in the image, Gauss-Jordan (8.3.85) takes 234ms and through the determinant (8.3.86) 94ms.
For the determinant, in 8.3.86, it follows Leiniz formula. (See Leibinz formula at http://en.wikipedia.org/wiki/Determinant)

047ae745985e14fdf723cfc222464eed

Both verifications are:
93bc51ccc2fe7d06bea3676acd1377d7

and:
baa498f38c212ea2a53cb27b8c6a6fc6

xrjf 230 Posting Whiz

You're right again. I've been very imprecise, mostly trying to use few words. When previous version, 8.3.35, tries to calculate A^-1 through Gauss-Jordan times out at 1 minute, the longer configurable time. I suspect this is due to an error, because the polynomials degree involved increase too much. Calculations not only involve numbers but polynomials, although this is not a reason to take so long.
I'll try to fix the method and come back with timing as, in theory, Gauss-Jordan should be quicker.

xrjf 230 Posting Whiz

Here is the reason I was working with permutations: to obtain the determinant and the inverse of a matrix. The calculator already had a method to retrieve the inverse (Gauss-Jordan through absolute pivot), but it was extremely slow. For a 5x5 matrix it could take about one minute to resolve. Now, for the input:
roots(det(A))@A=(3,a,a,a,a|a,3,a,a,a|a,a,3,a,a|a,a,a,3,a|a,a,a,a,3)
it takes 203ms, more than 300 times faster! and, now a days, one minute is much more.
I'll explain the input:
1) Obtain the determinant of matrix A, i.e. a polynomial P(a) =(4a+3)(a-3)^4.
(corresponds to function det(A) in the input).
2) Obtain the roots of P(a) (specified in function roots(...))
3) Matrix A is a 5x5 matrix (corresponds to @A=.... )
3,a,a,a,a
a,3,a,a,a
a,a,3,a,a
a,a,a,3,a
a,a,a,a,3
The user's interface looks like this:

5539f93ebe10d791883b03ae26530d5c

xrjf 230 Posting Whiz

Right, as long as time is no problem.

xrjf 230 Posting Whiz

The present code snippet just does an especific task. This is, given an ordered sequence of natural numbers, starting at zero, generate all the different permutations there can be. When we talk about permutations, the order of the sequence does matter. So, the sequence 0, 1, 2 differs from 2, 0, 1.
For example, think about a 4-7-2 lock combination sequence. Changing the sequence to 2-7-4 would not open the lock, of course. Properly speaking in mathematics, we are talking about permutations, because the order does matter. On the other hand, if the order did not matter, we would be talking about combinations.
So, what does present Console application do? First, asks for how large the sequence must be. Possible values of N must be greater or equal to 3 and less or equal to 10 (3<=N<=10). Then asks if the sequence generation must be saved into a text file and/or displayed. After the sequence is generated, requests if the generated N! permutations should be verified. All of them should be different, this is, there must be no 2 or more equal sequences. If you play around with the application, changing just one of the numbers of the variable vTable()(), for instance, changing New Int32() {1, 2, 3} into New Int32() {1, 1, 3} implies failing any generation N>=4. Any change to the next array New Int32() {3, 1, 3, 1} would imply failing for N>=5.
The table is taken from http://comjnl.oxfordjournals.org/content/6/3/293.full.pdf and it is …

xrjf 230 Posting Whiz

Most probably, version 8.4.7 will be the last of the 8.4.x sequence. With respect to the previous version it has incorporated the roots' finding function for polynomials. This is achived by passing a complex array to the Eval() method:

     Dim cplxRoots() As Complex = Nothing
     '  Evaluate:
     If Not eP.Eval(result, vNames, vValues, cplxRoots) Then
         Exit Try
     End If

If, on the return, 'cplxRoots' is not 'Nothing' the array contents will be the polynomial's roots. Each entry of the array will be one of the roots. Let's say the polynomial is x^3-1 and we need to know the roots. So, we enter roots(x^3-1) to call the 'roots' function, and click on Calculate:
fae319cc1570fcca7b6b74c2f01d4274

Because a third degree polynomial has three roots, the output shows us the three roots. Polynomial x^3-1 has one real root and two complex roots, conjugates.

Note: don't forget to clear the variables' box under the label 'Variable = value'. Otherwise if 'x' has been set to a value, x^3-1 won't be treated as a polynomial, but as a value, and therefore no roots will be found!:

db813fa59098677be649451fe2c8a3f7

xrjf 230 Posting Whiz
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Image
Imports System.IO
Imports mates8

Partial Class fnGrapher
    Inherits System.Web.UI.Page
    Dim nID As Int32

    Const nFn As Int32 = 4
    Const nDiv As Int32 = 10
    Public Const w As Int32 = 600
    Public Const h As Int32 = 600
    Dim vMtxParser(nFn - 1) As matrixParser
    Dim vPoly(nFn - 1) As Polynomial, iP As Int32
    Dim oVars(nFn - 1) As VarsAndFns
    Dim vFn() As String
    Dim vIsEmptyStr(nFn - 1) As Boolean
    Dim vIsPoly(nFn - 1) As Boolean
    Dim vDbl(3) As Double
    Dim sErrMsg As String = "Graphic n/a"
    Dim min As Single = Single.MaxValue
    Dim max As Single = -min
    Dim cImg As HtmlImage
    Dim origH, origW As Int32
    Dim marginPt0 As New Point(110, 60)
    Dim marginPt1 As New Point(100, 50)
    Dim iComplexPts, iOutOfRange As Int32
    Const margDch As Int32 = 65

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim sImagePath As String = MapPath("~/grTable.png")
        Try
            lblMessage.Visible = False
            lblMessage.Text = ""
            iComplexPts = 0 : iOutOfRange = 0
            cImg = New UI.HtmlControls.HtmlImage
            cImg.Alt = "Graphic"
            cImg.Attributes.Add("class", "grPos")

            GetGraphic(sImagePath)

            Me.Panel1.Controls.Add(cImg)
            If iComplexPts OrElse iOutOfRange Then
                If iComplexPts Then
                    lblMessage.Text = iComplexPts.ToString + " complex points couldn't be drawn."
                End If
                If iOutOfRange Then
                    lblMessage.Text += iOutOfRange.ToString + " out of range points couldn't be drawn."
                End If
            End If
        Catch ex As Exception
            If lblMessage.Text.Length = 0 Then
                If iComplexPts OrElse iOutOfRange Then
                    If iComplexPts Then
                        lblMessage.Text = iComplexPts.ToString + " complex points couldn't be drawn."
                    End If
                    If …
xrjf 230 Posting Whiz

Because of some fixes I take the opportunity to attach a zip file including the image, mates8.dll (v8.3.58), the markup file and the code behind file.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="fnGrapher.aspx.vb" Inherits="fnGrapher" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Function grapher</title>
    <style type="text/css" media="screen">
        body { font-family: Calibri;
               font-size: medium;
        }
    .margin { margin-left: 10px; position:relative; top:0px;}
    .grPos { position:relative; left: 20px; top: 0px;}
    </style>
        <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) / 1000; } …
xrjf 230 Posting Whiz

As you may see in the images about Mates8 (version 8.4.6), it can manage polynomials, although finds no roots yet. Multiplication and division of polynomials can be detailed.

d1c2484283ce1433f4b0cc8eccea7856

fd3e1a082288edc1e0a9bf8cd2894acb

c7f56423e675e2dfa5e7ade7da60c291

xrjf 230 Posting Whiz

For convinience's sake, attached, you may find the zip including only the executable and the full source code, fixed. I hope, for next time, there'll be some algebra operations.