VB编程中,如何在文件路径名里插入变量
我要做一个幻灯片,每点击一下Command1按钮就在Image1里切换一张图片,而原图片的名字是有规律的,就是p(1)、p(2)、p(3)、p(4)……,我定义的了一个变...
我要做一个幻灯片,每点击一下Command1按钮就在Image1里切换一张图片,而原图片的名字是有规律的,就是p(1)、p(2)、p(3)、p(4)……,我定义的了一个变量n,如何才能在调用Image1.Picture = LoadPicture(App.Path + "\g(1).gif")时,使文件名里含有变量n ?
而Image1.Picture = LoadPicture(App.Path + "\g(n).gif") 这个是错的!
我搞不懂,只好繁琐一点写成
Private Sub Command1_Click()
Static n As Integer
n = n + 1
If n = 1 Then
Image1.Picture = LoadPicture(App.Path + "\g(1).gif")
ElseIf n = 2 Then
Image1.Picture = LoadPicture(App.Path + "\g(2).gif")
ElseIf n = 3 Then
Image1.Picture = LoadPicture(App.Path + "\g(3).gif")
ElseIf n = 4 Then
Image1.Picture = LoadPicture(App.Path + "\g(4).gif")
ElseIf n = 5 Then
Image1.Picture = LoadPicture(App.Path + "\g(5).gif")
ElseIf n = 6 Then
Image1.Picture = LoadPicture(App.Path + "\g(6).gif")
ElseIf n = 7 Then
Image1.Picture = LoadPicture(App.Path + "\g(7).gif")
ElseIf n = 8 Then
Image1.Picture = LoadPicture(App.Path + "\g(8).gif")
ElseIf n = 9 Then
Image1.Picture = LoadPicture(App.Path + "\g(9).gif")
ElseIf n = 10 Then
Image1.Picture = LoadPicture(App.Path + "\g(10).gif")
ElseIf n = 11 Then
n = 0
End If
End Sub
但如果图片太多,那就悲催了。。求大虾指点迷津!!先谢了 ! 展开
而Image1.Picture = LoadPicture(App.Path + "\g(n).gif") 这个是错的!
我搞不懂,只好繁琐一点写成
Private Sub Command1_Click()
Static n As Integer
n = n + 1
If n = 1 Then
Image1.Picture = LoadPicture(App.Path + "\g(1).gif")
ElseIf n = 2 Then
Image1.Picture = LoadPicture(App.Path + "\g(2).gif")
ElseIf n = 3 Then
Image1.Picture = LoadPicture(App.Path + "\g(3).gif")
ElseIf n = 4 Then
Image1.Picture = LoadPicture(App.Path + "\g(4).gif")
ElseIf n = 5 Then
Image1.Picture = LoadPicture(App.Path + "\g(5).gif")
ElseIf n = 6 Then
Image1.Picture = LoadPicture(App.Path + "\g(6).gif")
ElseIf n = 7 Then
Image1.Picture = LoadPicture(App.Path + "\g(7).gif")
ElseIf n = 8 Then
Image1.Picture = LoadPicture(App.Path + "\g(8).gif")
ElseIf n = 9 Then
Image1.Picture = LoadPicture(App.Path + "\g(9).gif")
ElseIf n = 10 Then
Image1.Picture = LoadPicture(App.Path + "\g(10).gif")
ElseIf n = 11 Then
n = 0
End If
End Sub
但如果图片太多,那就悲催了。。求大虾指点迷津!!先谢了 ! 展开
3个回答
展开全部
Image1.Picture = LoadPicture(App.Path + "\g(" & n & ").gif")
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Image1.Picture = LoadPicture(App.Path + "\g(" + n + ").gif")
追问
不行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Image1.Picture = LoadPicture(App.Path + "\g(" + n + ").gif")
追问
不行,已解决
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询