Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 将图片从Excel添加到PictureBox,但显示空图片_Vb.net_Excel_Picturebox - Fatal编程技术网

Vb.net 将图片从Excel添加到PictureBox,但显示空图片

Vb.net 将图片从Excel添加到PictureBox,但显示空图片,vb.net,excel,picturebox,Vb.net,Excel,Picturebox,我有一个代码,可以添加一组多张图片。然后我的程序在Win7和Office 2010上运行良好,picturebox可以显示图片。 但是,当我的程序在WinXP和office 2003中运行时。它不能显示任何图片。有人知道为什么吗 这是我的密码 For Each sp As EXCEL.Shape In xlsheet.Shapes sp.Copy() picname = sp.Name

我有一个代码,可以添加一组多张图片。然后我的程序在Win7和Office 2010上运行良好,picturebox可以显示图片。 但是,当我的程序在WinXP和office 2003中运行时。它不能显示任何图片。有人知道为什么吗

这是我的密码

For Each sp As EXCEL.Shape In xlsheet.Shapes
                    sp.Copy()
                    picname = sp.Name

                    If Strings.Left(picname, 5) = "Group" Then
                        If Clipboard.ContainsImage Then
                            MsgBox("have image")
                            xlPic = Clipboard.GetImage
                            PictureBox1.Image = xlPic
                            ImageList1.Images.Add(xlPic)
                        End If
                    End If
                    For Each Me.xlsheet In xlbook.Sheets
                        If xlsheet.Name.Equals("Reference") Then
                            xlsheet = xlapp.Sheets("Reference")
                            timerlamp.Enabled = True
                            For Each sp1 As EXCEL.Shape In xlsheet.Shapes
                                If Strings.Left(picname, 5) = "Group" Then
                                    sp1.Copy()
                                    If Clipboard.ContainsImage Then
                                        xlPic = Clipboard.GetImage
                                        ImageList1.Images.Add(xlPic)
                                    End If
                                End If
                            Next
                        Else
                            Exit For
                        End If
                    Next
                Next

我在理解你的代码时遇到了一些困难。为什么有这么多重复的代码?为什么迭代所有工作表的循环在迭代工作表中所有形状的循环中?对不起,我还是程序员的初学者。如果可以的话,你能告诉我需要做什么来改变我的代码不重复吗?