Adding Graphics to a User Form

[ggj A listing on a form can be even more helpful if a corresponding graphic is added to the form, as shown in Figure 9.12.

The following code displays the photograph corresponding to the selected employee from the ListBox:

Private Sub lb_EmpName_Change() Dim EmpFound As Range With Range("EmpList")

Set EmpFound = .Find(lb_EmpName.Value) If EmpFound Is Nothing Then

MsgBox ("Employee not found!") lb_EmpName.Value = ""

Exit Sub


With Range(EmpFound.Address)

tb_EmpPosition = .Offset(0, 1) tb_HireDate = .Offset(0, 2) On Error Resume Next Img_Employee.Picture = LoadPicture _ ("C:\Excel VBA 2003 by Jelen & Syrstad\" & EmpFound &

On Error GoTo 0 End With End If


End With

Figure 9.12

Use a graphic to enhance identification.

Animation Excell Dans Userform
0 0

Post a comment