好久沒碰VB6.0了,有點技術問題,需要大神幫忙。
網上找的一篇編程文章《VB制作幻燈片播放器》
地址:http://www.doc88.com/p-9394448228185.html
運行程序中出現“編譯錯誤,變數未定義”,如下圖。
請教如何修改代碼,說是未對file1.定義


界面如下:

完整代碼如下:
Option Explicit
Dim Message, Title, Default, MyValue
Dim Pi
Dim i As Integer
Private Sub Image3_Click()
End
End Sub
Private Sub Image4_Click()
Image2.Visible = False
If Pi = 0 Then
MsgBox ("歡迎觀看!")
Else
Pi = Pi - 1
End If
Image1.Stretch = False
Image1.Visible = False
Image1.Picture = LoadPicture(App.Path + "\" + File1.List(Pi))
If Image1.Height > Form1.Height Then
Image1.Width = Image1.Width * Form1.Height / Image1.Height
Image1.Height = Form1.Height
Image1.Stretch = True
Image1.Move (Form1.Width - Image1.Width) / 2, 0
Else
Image1.Move (Form1.Width - Image1.Width) / 2, (Form1.Height - Image1.Height) / 2
End If
Image1.Visible = True
End Sub
Private Sub Form_Click()
Image2.Visible = False
If Pi = File1.ListCount - 1 Then
MsgBox ("謝謝觀看!")
Else
Pi = Pi + 1
End If
Image1.Stretch = False
Image1.Visible = False
Image1.Picture = LoadPicture(App.Path + "\" + File1.List(Pi))
If Image1.Height > Form1.Height Then
Image1.Width = Image1.Width * Form1.Height / Image1.Height
Image1.Height = Form1.Height
Image1.Stretch = True
Image1.Move (Form1.Width - Image1.Width) / 2, 0
Else
Image1.Move (Form1.Width - Image1.Width) / 2, (Form1.Height - Image1.Height) / 2
End If
Image1.Visible = True
End Sub
Private Sub Form_Load()
Form1.Move 0, 0, Screen.Width, Screen.Height
File1.Path = App.Path
File1.Pattern = ("* .bmp; * jpg; * gif")
Image2.Visible = False
Image1.Stretch = False
Image1.Visible = False
Image1.Picture = LoadPicture(App.Path + "\" + File1.List(0))
If Image1.Height > Form1.Height Then
Image1.Width = Image1.Width * Form1.Height / Image1.Height
Image1.Height = Form1.Height
Image1.Stretch = True
Image1.Move (Form1.Width - Image1.Width) / 2, 0
Else
Image1.Move (Form1.Width - Image1.Width) / 2, (Form1.Height - Image1.Height) / 2
End If
Text1.Visible = False
Image1.Visible = True
Image3.Move (Form1.Width - Image3.Width), (Form1.Height - Image4.Height * 2)
Image4.Move (Form1.Width - Image3.Width), (Form1.Height - Image4.Height)
Text1.Move (Form1.Width - Text1.Width) / 2, (Form1.Height - Text1.Height * 2)
End Sub
Private Sub Form_MouseMove(Button As Integer, shift As Integer, X As Single, Y As Single)
Text1.Visible = False
End Sub
Private Sub Image1_MouseMove(Button As Integer, shift As Integer, X As Single, Y As Single)
Text1.Visible = True
Text1.Text = File1.List(Pi)
End Sub
Private Sub Image1_Click()
Dim Msg, Style, Title, help, Ctxt, Response, mystring
Image2.Visible = False
If Pi = File1.ListCount - 1 Then
Msg = "謝謝觀看!"
Style = vbYesNo + vbDefaultButton2
Title = "播放完畢!"
help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(Mag, Style, Title, help, Ctxt)
If Response = vbYes Then
mystring = "Yes"
End
Else
mystring = "No"
End If
Else
Pi = Pi + 1
End If
Image1.Stretch = False
Image1.Visible = False
Image1.Picture = LoadPicture(App.Path + "\" + File1.List(Pi))
If Image1.Height > Form1.Height Then
Image1.Width = Image1.Width * Form1.Height / Image1.Height
Image1.Height = Form1.Height
Image1.Stretch = True
Image1.Move (Form1.Width - Image1.Width) / 2, 0
Else
Image1.Move (Form1.Width - Image1.Width) / 2, (Form1.Height - Image1.Height) / 2
End If
Image1.Visible = True
End Sub
uj5u.com熱心網友回復:
初步觀察應該是file控制元件,拖一個到表單上....uj5u.com熱心網友回復:
應該是這個原因。
uj5u.com熱心網友回復:
加了一個list控制元件,繼續除錯,實時錯誤"76".我的project保存在C盤VB Form檔案夾下面。
是不是程式參考的路徑,絕對路徑和相對路徑的問題,該如何修改呢?



uj5u.com熱心網友回復:
給你說了是“File控制元件”,你拖個List控制元件。
uj5u.com熱心網友回復:
File控制元件是標準控制元件,它的tooltip是 "FileListBox”,你自己在控制元件工具箱中找找看。uj5u.com熱心網友回復:
寫錯了,是File控制元件,呵呵。uj5u.com熱心網友回復:
除錯程序中,實時錯誤"76".是不是程式參考的路徑,絕對路徑和相對路徑的問題,該如何修改呢?
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/75280.html
標籤:VB基礎類
上一篇:VB做一個虛擬鍵盤
