Option Explicit
Public i As Integer
Dim a, bPrivate Sub Command1_Click()
Dim x As Integer
x = MsgBox("你确定保存吗?", vbYesNo + vbDefaultButton1 + vbQuestion, "友情提示") 'msgbox调用,创建窗体
If x = 6 Then
Dim strFileName As String '文件名
Dim lngHandle As Long '句柄
Dim strWrite As String
'要写入的文本内容
strFileName = "进度.txt"
lngHandle = FreeFile()
'取得句柄
'准备要写入的内容
strWrite = i
'For后面的参数表示以何种方式打开文件,Input是读取,Output是覆盖写入,Append是追加写入
Open strFileName For Output As lngHandle
'打开文件
Print #lngHandle, strWrite
'写入文本
Close lngHandle
'关闭文件
a.Controls.stop
a.Close
Set a = Nothing
End
End If
End SubPrivate Sub Picture3_Click()
Dim strFileName As String
'文件名
Dim lngHandle As Long
'文件句柄
Dim strAll As String
'所读取的文本文件的所有内容
Dim strLine As String
'在循环中存放每行的内容
strFileName = "进度.txt"
'获得文件的句柄
lngHandle = FreeFile()
'For后面的参数表示以何种方式打开文件,Input是读取,Output是覆盖写入,Append是追加写入
Open strFileName For Input As lngHandle
'循环直到文件尾
Do While Not EOF(lngHandle)
'每次读取一行存放在strLine变量中
Line Input #lngHandle, strLine
'每次读取都把所读到的内容连接到strAll变量,由于Line Input去掉了换行符,所以这里补上
strAll = strAll & strLine & vbCrLf
Loop
'显示得到的全部分内容
i = strAll
Image1.Picture = LoadPicture(App.Path & "\images\背景1.jpg")
Picture3.Visible = False
Picture4.Visible = True
Command1.Visible = True
Picture4.Picture = LoadPicture(App.Path & "\images\" & i & ".jpg")
If strAll >= 7 & strAll < 14 Then
Image1.Picture = LoadPicture(App.Path & "\images\外背景1.jpg")
Else
If strAll >= 14 & strAll < 200 Then
Image1.Picture = LoadPicture(App.Path & "\images\外背景2.jpg")
End If
End If
End Sub
Private Sub Form_Load()
Set a = CreateObject("wmplayer.ocx")
Set b = CreateObject("wmplayer.ocx")
a.url = App.Path & "\music\初始音乐.mp3"
a.settings.playCount = 99999
End Sub
Private Sub Form_Unload(Cancel As Integer)
b.Controls.stop
b.Close
Set b = Nothing
a.Controls.stop
a.Close
Set a = Nothing
End SubPrivate Sub Image2_Click()
i = 7
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Picture4.Visible = True
Image1.Picture = LoadPicture(App.Path & "\images\背景1.jpg")
Picture4.Picture = LoadPicture(App.Path & "\images\7.jpg")
Image1.Picture = LoadPicture(App.Path & "\images\外背景1.jpg")
End SubPrivate Sub Image3_Click()
i = 100
Image2.Visible = False
Image3.Visible = False
Image4.Visible = False
Picture4.Visible = True
Image1.Picture = LoadPicture(App.Path & "\images\背景1.jpg")
Picture4.Picture = LoadPicture(App.Path & "\images\7.jpg")
End SubPrivate Sub Picture1_Click()
Image1.Picture = LoadPicture(App.Path & "\IMAGES\背景1.jpg")
Picture4.Visible = True
Picture4.Picture = LoadPicture(App.Path & "\images\z.jpg")
Picture1.Visible = False
Picture2.Visible = False
Command1.Visible = True
Picture5.Visible = False
a.Controls.stop
a.Close
Set a = Nothing
Set a = CreateObject("wmplayer.ocx")
Set b = CreateObject("wmplayer.ocx")
b.url = App.Path & "\music\变化音乐.mp3"
b.settings.playCount = 99999
End SubPrivate Sub Picture2_Click()
Picture1.Visible = False
Picture2.Visible = False
Image1.Picture = LoadPicture(App.Path & "\images\读取背景.jpg")
Picture3.Visible = True
Picture5.Visible = False
End SubPrivate Sub Picture5_Click()
Dim msg As Integer
msg = MsgBox("你确定要退出吗?", vbYesNo + vbDefaultButton1 + vbQuestion, "友情提示") 'msgbox函数打开一个窗体
If msg = 6 Then
a.Controls.stop
a.Close
Set a = Nothing
End
End If
End SubPrivate Sub Picture4_Click()
Picture4.Picture = LoadPicture(App.Path & "\images\" & i & ".jpg")
i = i + 1
If i = 6 Then
Image2.Visible = True
Image3.Visible = True
Image4.Visible = True
Image1.Picture = LoadPicture(App.Path & "\images\背景2.jpg")
Picture4.Visible = False
Image2.Picture = LoadPicture(App.Path & "\images\x1.jpg")
Image3.Picture = LoadPicture(App.Path & "\images\x2.jpg")
Image4.Picture = LoadPicture(App.Path & "\images\x3.jpg")
End If
If i = 14 Then
Image1.Picture = LoadPicture(App.Path & "\images\外背景2.jpg")
If i = 21 Then
Image1.Picture = LoadPicture(App.Path & "\images\外背景1.jpg")
If i = 21 Then
Image1.Picture = LoadPicture(App.Path & "\images\背景1.jpg")
If i = 25 Then
Image2.Visible = True
Image3.Visible = True
Image4.Visible = True
Picture4.Visible = False
Image2.Picture = LoadPicture(App.Path & "\images\2x1.jpg")
Image3.Picture = LoadPicture(App.Path & "\images\2x2.jpg")
Image4.Picture = LoadPicture(App.Path & "\images\2x3.jpg")
End If
End If
End If
End If
End Sub
我就是想知道2块儿,一个是保存后在运行为啥提示我文件已打开。还有就是我Picture3中strall的判断写的有问题吗?为啥达不到要求啊