日本裕仁天皇多少岁:VB难点问题

来源:百度文库 编辑:高考问答 时间:2024/04/20 20:02:54
看看下面的代码,,我有点不太明白
ReadRecentFiles
ClearRecentFiles

==的代码是什麽东西呀,VB中没有呀
是API
高手指点下呀
Option Explicit
Dim A_Name As String
Dim S_Name As String
Const MaxRFiles = 4

Private Sub Command2_Click()
ClearRecentFiles
End Sub

Private Sub Form_Load()
A_Name = "Demo"
S_Name = "RFile"
ReadRecentFiles
End Sub

Private Sub mExit_Click()
Unload Me
End Sub

Private Sub mLastFile_Click(Index As Integer)
UpdateRecentFiles Index
End Sub

WriteRecentFiles CommonDialog1.FileName

UpdateRecentFiles fIndex

Private Sub WriteRecentFiles(FileName As String)
Dim fileptr As Integer
If Len(Trim(FileName)) Then
fileptr = Val(GetSetting(A_Name, S_Name, "FirstFile", "0"))
fileptr = IIf(fileptr - 1 >= 0, fileptr - 1, MaxRFiles - 1)
SaveSetting A_Name, S_Name, "FirstFile", fileptr & ""
SaveSetting A_Name, S_Name, "File" & fileptr, FileName
ReadRecentFiles
End If
End Sub

Private Sub ReadRecentFiles()
Dim i As Integer
Dim fileptr As Integer
Dim rFile As String
Dim rCount As Integer
'第一个文件的位置
fileptr = Val(GetSetting(A_Name, S_Name, "FirstFile", "0"))
rFile = GetSetting(A_Name, S_Name, "File" & fileptr, "")
rCount = 0
Do While Len(rFile) And rCount < MaxRFiles
mLastFile(rCount).Caption = "&" & (rCount + 1) & " " & rFile
mLastFile(rCount).Visible = True
fileptr = IIf(fileptr + 1 < MaxRFiles, fileptr + 1, 0)
rFile = GetSetting(A_Name, S_Name, "File" & fileptr, "")
rCount = rCount + 1
Loop
If rCount = 0 Then
mLastFile(rCount).Visible = True
mLastFile(rCount).Caption = "无历史文件"
rCount = 1
End If
For i = rCount To MaxRFiles - 1
mLastFile(i).Visible = False
Next
End Sub

Private Function InRecentFiles(strFile As String) As Integer
Dim i As Integer
Dim bFound As Boolean

InRecentFiles = MaxRFiles + 1

Public Sub ClearRecentFiles()
On Error Resume Next
Dim i As Integer
DeleteSetting A_Name, S_Name, "FirstFile"
For i = 0 To MaxRFiles
DeleteSetting A_Name, S_Name, "File" & i

ReadRecentFiles 从注册表中取出你保存的最近文件信息
ClearRecentFiles 从注册表中清除你保存的最近文件信息
SaveSetting和GetSetting是vb提供的读注册表 的api.
ReadRecentFiles 和ClearRecentFiles 是程序中编写的.

那些都是一些API函数的,你最好找一些API函数的书看看

简单的函数,学编程最好把数学和外语两门功课抓好~!!!