1. Home
  2. Computing & Technology
  3. Visual Basic

Chapter 10 - Using Modules and Procedures - Part 2

By , About.com Guide

7 of 7

The Rest of the Code

~~~~~~~~~~~~~~~~~~~~~~~~~
Private Sub Button1_Click( _
  ByVal sender As System.Object, _
  ByVal e As System.EventArgs) _
  Handles Button1.Click
  Dim i As Integer
  For i = 1 To 10
    If TryDisk("a:\fileopen.bmp") = True Then Exit For
  Next i
  If i > 10 Then
    MsgBox("File Load feature disabled")
    Button1.Enabled = False
  End If
End Sub
Private Function TryDisk( _
  ByVal PictureLocation As String) _
  As Boolean
  Try
    PictureBox1.Image = _
      System.Drawing.Bitmap.FromFile(PictureLocation)
    Return True
  Catch
    MsgBox("Insert the disk in drive A, then click OK!")
    Return False
  End Try
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~

Explore Visual Basic
By Category
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Using Modules and Procedures - Part 2

©2009 About.com, a part of The New York Times Company.

All rights reserved.