关于VB中GetApp的问题

来源:百度知道 编辑:UC知道 时间:2024/06/15 09:45:43
If Ch2.Value = 1 Then
sql = ReadFile(GetApp & "Data.sql")
s = Split(sql, vbCrLf)
For i = 0 To UBound(s)
If Trim(s(i)) <> "" Then cnMain.Execute s(i)
Next
MsgBox "成功新建测试数据。", vbInformation
b = True
End If
这个程序是什么意思啊?特别是sql=ReadFile(GetAPP&"Data.sql")的意思。

If Ch2.Value = 1 Then '如果单选按钮2选中
sql = ReadFile(GetApp & "Data.sql") '以路径参数为GetApp & "Data.sql"调用自定义函数ReadFile 返回结果赋值给sql
s = Split(sql, vbCrLf) '用split分离出以回车换行为分隔符的字符串
For i = 0 To UBound(s) '循环该s数组变量
If Trim(s(i)) <> "" Then cnMain.Execute s(i)'如果s(i)元素不为空则执行 sql语句
Next
MsgBox "成功新建测试数据。", vbInformation '弹出对话框
b = True
End If

getapp是一个函数:

'获得程序所在目录
Function GetApp() As String
GetApp = App.Path
If Right$(GetApp, 1) <> "\" Then GetApp = GetApp & "\"
End Function

参考更多:http://hi.baidu.com/st%5Fheping