Visual Basic Express 2008 Programming Examples.

These are exerts from the Motion Patrol project files (download them now)

 

Dim MyPictureBox As New PictureBox()

MyPictureBox.Name = "MyPictureBox"

MyPictureBox.SetBounds((Me.Width - 640) / 2, (Me.Height - 480) / 2, 640, 480)

myForm.Controls.Add(MyPictureBox)

 

Try

        Dim FS As New IO.FileStream(fileList(PicNumber), IO.FileMode.Open)

        MyPictureBox.Image = Image.FromStream(FS).GetThumbnailImage(320, 240, Nothing, Nothing)

        FS.Close() : FS.Dispose()

Catch

        MsgBox("DisplayPic Msg 1 " & ErrorToString() & " PicNum " & PicNumber & " FileCnt " & fileList.Count)

End Try

 

Private Sub InitializeTimer1()

    'Set Timer Interval 1000 = 1 sec

    If FramePerSecToolStripMenuItem.Checked Then

            Timer1.Interval = 1000

    ElseIf FramesPerSecToolStripMenuItem1.Checked Then

            Timer1.Interval = 200

     Else

            Timer1.Interval = 500

    End If

            Timer1.Start()

  End Sub

 

    Private Sub Timer1_Tick(ByVal Sender As Object, ByVal e As EventArgs) Handles Timer1.Tick

        OddEvenCnt += 1

        If OddEvenCnt Mod 2 = 0 Then

                OddEven = "Even"

        Else

                OddEven = "Odd"

        End If

 

        If OddEvenCnt > 10000 Then

                OddEvenCnt = 1

        End If

 

        Dim oWatch As New Stopwatch

         oWatch.Start()

         CaptureImage(OddEven)

        oWatch.Stop()

        TextBox4.Text = oWatch.ElapsedMilliseconds.ToString

 

    End Sub