问题~!谢谢大哥们!

viking7 2004-03-16 09:09:50
GetPrivateProfileString "No2", "no2", "", getstr, 50, inipath
showstr = getstr + "\"
trimgetstr = Val(getstr)
Debug.Print showstr
Print trimgetstr
For i = 0 To trimgetstr Step 1
GetPrivateProfileString "folder", "foldername" & i, "", getstr2, 100, inipath
filedir = "h:\test\" + getstr2
Debug.Print filedir
MkDir filedir
DoEvents
Next i

这段程序有问题吗?

主要是看mkdir filedir那句,提示有问题,但是在该路径上又可以创建这个文件夹的
...全文
16 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilaclone 2004-03-19
  • 打赏
  • 举报
回复
getstr取值不正确,用函数来取得
'********************************************************************************
'* 模块名称:mdlInIFile
'* 功能描述:处理配置文件模块
'* 设 计:阿九
'* 作 者:阿九
'********************************************************************************

Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpString As Any, _
ByVal lpFileName As String) As Long

'********************************************************************************
'** 函数功能:从ini配置文件中读取指定段名、关键字名的值
'** 调用语法: GetInIKeyValue(SectionName as string,KeyName As String,FileName As String)
'** 参数说明:
'** SectionName :段名
'** KeyName :关键字名
'** FileName :ini文件名包括路径
'** 返 回 值:
'** String :返回关键字值
'** 处理说明:
'** 调用API函数GetPrivateProfileString
'******************************************************************************
Public Function GetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal FileName As String) As String
Dim KeyValue$
Dim strTmp As String

KeyValue$ = String$(512, " ")
GetPrivateProfileString SectionName, KeyName, "", KeyValue$, 512, FileName
strTmp = Trim(KeyValue$)
GetInIKeyValue = Left(strTmp, Len(strTmp) - 1)
End Function

'********************************************************************************
'** 函数功能:从ini配置文件中写入指定段名、关键字名及值
'** 调用语法: SetInIKeyValue(SectionName as string,KeyName As String,KeyValue as string ,FileName As String)
'** 参数说明:
'** SectionName :段名
'** KeyName :关键字名
'** KeyValue :关键字值
'** FileName :ini文件名包括路径
'** 返 回 值:
'** 处理说明:
'** 调用API函数WritePrivateProfileString
'******************************************************************************
Public Sub SetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal KeyValue As String, _
ByVal FileName As String)
Dim lng As Long

lng = WritePrivateProfileString(SectionName, KeyName, KeyValue, FileName)
End Sub

'********************************************************************************
'** 函数功能:读取系统目录路径
'** 调用语法: GetSysDir()
'** 参数说明:
'** 返 回 值:
'** String :系统目录
'** 处理说明:
'** 调用API函数GetSystemDirectory
'******************************************************************************
Public Function GetSysDir() As String
Dim sysDir$
Dim strTmp As String

sysDir = String$(128, " ")
GetSystemDirectory sysDir$, 127
strTmp = Trim(sysDir$)
GetSysDir = Left(strTmp, Len(strTmp) - 1)
End Function
viking7 2004-03-16
  • 打赏
  • 举报
回复
顶一下,谢谢
viking7 2004-03-16
  • 打赏
  • 举报
回复

????

我是说h:\test存在啊,可是下级目录是我要创建的,我在想是不是一开始定义
getstr2的时候这样有问题的,dim getstr2 as string*100

这样的话,如果用trim函数就没有作用了是不是?
hhyttppd 2004-03-16
  • 打赏
  • 举报
回复
存在就不行了.
viking7 2004-03-16
  • 打赏
  • 举报
回复
存在的
online 2004-03-16
  • 打赏
  • 举报
回复
filedir = "h:\test\" + getstr2
Debug.Print filedir
MkDir filedir

mkdir只能一级一级的建立目录
请确定h:\test\已经存在
viking7 2004-03-16
  • 打赏
  • 举报
回复
哦,好像是那个getstr2的问题?有没有什么方法,定义一个数组,每个数代表一个foldername?

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧