Hi,

Trying out VB.Net 2005 (the free one).

Coming from VBA/VB6 environment, things are slightly skewed.

Can someone please tell me where I am going wrong with the following code?
Code:
    Private Sub btnTry1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTry1.Click
        ' prime numbers - to be divisable only by themselves and 1

        Dim lngLoop As Long, lngMax As Long, lngInnerLoop As Long
        Dim blnPrime As Boolean
        Dim dblPerc As Double
        Dim dteS As Date, dteCalc As Date


        If txtMax.Text.Length = 0 Then txtMax.Text = "100"
        If CLng(txtMax.Text) > 2000000 Then txtMax.Text = "2000000"

        lngMax = CLng(txtMax.Text)
        dteS = Now

        Me.Cursor = Cursors.WaitCursor

        For lngLoop = 1 To lngMax
            blnPrime = True

            If chkVisual.CheckState = CheckState.Checked Then
                dblPerc = CDbl(lngLoop) / CDbl(lngMax)
                pbarOuter.Value = dblPerc * 100
                lblPBar2.Text = Format(dblPerc, "#0%")
            End If

            If lngLoop > 2 Then
                For lngInnerLoop = 2 To (lngLoop - 1)
                    If chkVisual.CheckState = CheckState.Checked Then
                        dblPerc = CDbl(lngInnerLoop) / CDbl(lngLoop)
                        pbarInner.Value = dblPerc * 100
                        lblPbar1.Text = Format(dblPerc, "#0%")
                        'Debug.Print(Format(dblPerc, "#0%"))
                    End If


                    If lngLoop Mod lngInnerLoop = 0 Then
                        blnPrime = False
                        Exit For
                    End If

                Next
            End If

            '---- add to list
            If blnPrime Then
                lstPrimes.Items.Add(lngLoop.ToString)
            End If

            If chkVisual.CheckState = CheckState.Checked Then
                lblPbar1.Refresh()
                lblPBar2.Refresh()
                'Me.Refresh()
            End If
        Next

        pbarInner.Value = 0
        pbarOuter.Value = 0
        lblPbar1.Text = ""
        lblPBar2.Text = ""
        lblPbar1.Refresh()
        lblPBar2.Refresh()

'---- \\//  \\//  \\//
        'dtecalc = now - dtes
        'lblTimeTaken.Text = "Time Taken : " & dteCalc.Hour & ":" & dteCalc.Minute & ":" & dteCalc.Second & "::" & dteCalc.Ticks
'---- //\\  //\\
        Me.Cursor = Cursors.Arrow

    End Sub
The bit just above... plus any other immediate problems.

I am self taught / from book so I know I have made loads of mistakes...

Thanks in advance