xrjf 230 Posting Whiz

Sorry, I thought your code was for WPF. So, it should be:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles ListView1.KeyDown
        If e.Modifiers = Keys.Alt AndAlso _
        e.KeyCode = Keys.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub
xrjf 230 Posting Whiz

I would code this way:

    Public Sub listView1_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs) Handles ListView1.KeyDown
        If e.Key = Key.System AndAlso _
        e.SystemKey = Key.Delete Then
            If ListView1.SelectedItems.Count Then
                Dim item As ListViewItem = ListView1.SelectedItems(0)
                ListView1.Items.Remove(item)
                e.Handled = True
            End If
        End If
    End Sub
xrjf 230 Posting Whiz

Are you talking about a ListView, a container of images? Or perhaps are you refering to a listbox filled with items?

xrjf 230 Posting Whiz

I don't know exactly what is your code, but perhaps you could call createTable() passing the selected index as argument:

Sub createTable(selectedIndex As Int32)
    Dim n As Int32 = 200
    Static vinte(-1) As Int32
    Try
        If vinte.Length = 0 Then
            ' initialize vinte() just in the first call: '
             ReDim vinte(n - 1)
           Dim rnd As New Random
            For i = 0 To n - 1
                vinte(i) = i + 1
            Next
            Dim vByte(n - 1) As Byte
            rnd.NextBytes(vByte)
            Array.Sort(vByte, vinte)
        End If

        Dim con As New SqlClient.SqlConnection("data source=ADMIN-PC\SQLEXPRESS;initial catalog=Warehouse;Integrated Security=True")
        Dim cmd As New SqlCommand()
        cmd.Connection = con
        con.Open()
        cmd.CommandText = "CREATE TABLE  'table" & selectedIndex & vinte(selectedIndex) & "'(ID int ,LastName varchar(255) NOT NULL,FirstName varchar(255),Age int, PRIMARY KEY (ID))"
        cmd.CommandType = CommandType.Text
        cmd.ExecuteNonQuery()
    Catch ex As Exception
        Throw ex
    End Try
End Sub
xrjf 230 Posting Whiz

Sorry, rnd should be an instance of Random class:

dim rnd as new Random()
xrjf 230 Posting Whiz

I guess the table names are being repeated, to avoid this problem you may set the 200 numbers, firstly ordered in vinteand then reorder randomly:

        Dim n As Int32 = 200
        Dim vinte(n - 1) As Int32
        For i As Int32 = 0 To n - 1
            vinte(i) = i + 1
        Next
        Dim vByte(n - 1) As Byte
        rnd.NextBytes(vByte)
        ' vByte() contains random entries and vinte() is ordered.'
        ' sort vByte (keys) and reorder vinte entries in the same'
        ' way. Suppose vByte=25,4,7 and vinte=1,2,3 after Array.Sort'
        Array.Sort(vByte, vinte)
        ' vByte=4,7,25 and vinte=2,3,1'
xrjf 230 Posting Whiz

There is missing a catch instruction after line #15:

catch  
    {  
    } 
xrjf 230 Posting Whiz

Why do you create a new instance of DataGridView in DataGridView dataGridView10 = new DataGridView(); ?? You should employ the same DataGridView present in the form.

xrjf 230 Posting Whiz

I would set datagrid's property AllowUserToAddRow to False and then manage to add a row by code. For example:

    Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click
        Try
            Dim caseNum As Int32 = 0
            If Int32.TryParse(tbCase.Text, caseNum) Then
                With DataGridView1
                    Dim index As Int32 = .Rows.Count
                    .Rows.Add()
                    .Rows(index).Cells(0).Value = caseNum
                End With
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
xrjf 230 Posting Whiz

Possibly you're look for a solution like the one on this threat Click Here

xrjf 230 Posting Whiz

...also it may be a static variable.

xrjf 230 Posting Whiz

The number does not increment because the error counter in erorcunt is defined locally, so each time there is a try for username and password erorcunt value is 0 and incremented to 1. Define this variable errorcntat class level.

xrjf 230 Posting Whiz

What's the message? In which line?

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

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, 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

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

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

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

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

Let's say it works from left to right.
If eax contains a 5, then:
cmp eax, 6 ; eax < 6
jb label ; will jump to label

pbj.codez commented: Exactly what I needed to see. Thank you again =D +0
xrjf 230 Posting Whiz

Long time since I wrote my last asm code, but I'll try to answer your questions:

69. mov dword [Guess], 5 states that a 5 will be moved to position pointed by Guess and value will occupy a double word length (32 bits). This is equivalent to 'guess = 5' in C, though in C you move always 32 bits: you don't just move 16 bits as in

mov word [guess], 5

79. The comment is right, it's eax * eax = 9
82. Line 81 compares eax and the value 'pointed' by 'Guess', this updates the status registers, so in #82 'jump if not below' jnb will jump if factor*factor >= Guess. This jump will avoid adding 2 in line 89 (Think that the 1st condition of line 28 is failing so it jumps to line 30, whose equivalent is line 91)
85 64-bit contents of EDX-EAX are divided by the operand (ebx), leaving a 32-bit quotient in eax and a 32-bit remainder in edx.
87 if edx was equal to 0 (#86) it will jump to end_while_factor, because now the 2nd condition (see line 28) is failing and addition in line #89 needs to be omitted.
92 'je' is a mnemonic for 'jump if equal' in the last 'cmp' executed.
pbj.codez commented: Thank you for the help. +0