| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1444 人关注过本帖
标题:[求助]VB程序代码分析!
只看楼主 加入收藏
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
 问题点数:0 回复次数:11 
[求助]VB程序代码分析!

我是新手,帮我看看吧!
真不好意思占用你们的时间?
谢谢拉!
帮帮忙!
能不能帮我把这些代码分析一下
好人!!~~~~~~~~~~~~~~~~~~~~~~~~~

搜索更多相关主题的帖子: 代码 好人 
2006-03-14 19:20
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 

Private Sub CmdDownload_Click()
Dim rstProduct As New ADODB.Recordset, rstRecord As New ADODB.Recordset, rstCompare As New ADODB.Recordset, rstDocuments As New ADODB.Recordset, rstNew As New ADODB.Recordset
Dim strDocRecord As String, strCompare As String, strDocuments As String, strProduct As String, strNotComplete As String, strNew As String
Dim i As Long, strTemp As String

On Error GoTo ErrAction

strDocRecord = "select productdwgcode,code,revnumber,filename from documents_record "
rstRecord.Open strDocRecord, Conn, adOpenKeyset, adLockReadOnly, adCmdText

If rstRecord.EOF Then ''Record 表中没有记录
strProduct = "select distinct productdwgcode from documents "
rstProduct.Open strProduct, Conn, adOpenKeyset, adLockReadOnly, adCmdText
i = 1
While Not rstProduct.EOF
Label1.Caption = "正在处理的产品:" & rstProduct.Fields("productdwgcode")
Label3.Caption = "共有" & rstProduct.RecordCount & "个产品,正在处理第" & i & "个产品!"
If CreateFolder(rstProduct.Fields("productdwgcode")) = True Then
strDocuments = "select productdwgcode,code,revnumber,filename,filetype,fileremark from documents where productdwgcode='" & rstProduct.Fields("productdwgcode") & "'order by productdwgcode,code,revnumber desc"
rstDocuments.Open strDocuments, Conn, adOpenKeyset, adLockReadOnly, adCmdText
strTemp = ""
While Not rstDocuments.EOF
If Right(rstDocuments.Fields("filename"), 4) = ".DWG" Or Right(rstDocuments.Fields("filename"), 4) = ".dwg" Then
If strTemp <> rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code") Then
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True Then
Conn.Execute "insert into documents_record (productdwgcode,code,filename,filetype,fileremark,revnumber) values('" & rstDocuments.Fields("productdwgcode") & "','" & rstDocuments.Fields("code") & _
"','" & rstDocuments.Fields("filename") & "','" & rstDocuments.Fields("filetype") & "','" & rstDocuments.Fields("fileremark") & "','" & rstDocuments.Fields("revnumber") & "')"
End If
strTemp = rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code")
End If
End If
rstDocuments.MoveNext
Wend
rstDocuments.Close
Set rstDocuments = Nothing
End If
i = i + 1
rstProduct.MoveNext
Wend
Label1.Caption = "下载完毕!"
Label3.Caption = "所有产品图纸下载完毕!"
txtLog.Text = txtLog.Text & "所有产品图纸下载完毕!" & Chr(13) + Chr(10)
rstProduct.Close
Set rstProduct = Nothing
rstRecord.Close
Set rstRecord = Nothing
Else ''Record 表中有记录
Label1.Caption = "正在核对已下载过的图纸!"
Label3.Caption = "正在检查是否有最新版本的图纸需要更新!"
While Not rstRecord.EOF ''检查是不是最新版本
strCompare = "select productdwgcode,code,revnumber,filename,filetype,fileremark from documents where productdwgcode='" & rstRecord.Fields("productdwgcode") & "' and code='" & rstRecord.Fields("code") & "' order by productdwgcode,code,revnumber desc"
rstCompare.Open strCompare, Conn, adOpenKeyset, adLockReadOnly, adCmdText
If Not rstCompare.EOF Then
If rstCompare.Fields("revnumber") > rstRecord.Fields("revnumber") Then
If Right(rstCompare.Fields("filename"), 4) = ".DWG" Or Right(rstCompare.Fields("filename"), 4) = ".dwg" Then
If GetFromFTP(rstCompare.Fields("productdwgcode"), rstCompare.Fields("code")) = True Then
Kill DRAWINGPATH & "\" & rstRecord.Fields("productdwgcode") & "\" & Left(rstRecord.Fields("filename"), Len(rstRecord.Fields("filename")) - 4) & ".dwf"
Conn.Execute "update documents_record set filename='" & rstCompare.Fields("filename") & "',revnumber='" & rstCompare.Fields("revnumber") & "',fileremark='" & rstCompare.Fields("fileremark") & "' where productdwgcode='" & rstRecord.Fields("productdwgcode") & "' and code='" & rstRecord.Fields("code") & "'"
txtLog.Text = txtLog.Text & "产品" & rstCompare.Fields("productdwgcode") & "的图纸" & rstRecord.Fields("filename") & "已更新为最新版本!" & Chr(13) + Chr(10)
End If
End If
End If
End If
rstCompare.Close
rstRecord.MoveNext
Wend
Set rstCompare = Nothing
rstRecord.Close
Set rstRecord = Nothing

Label1.Caption = "正在查找新图纸!"
Label3.Caption = "正在查找新图纸!" ''没有下载完全的
strProduct = "select distinct productdwgcode from documents where productdwgcode in (select distinct productdwgcode from documents_record)"
rstProduct.Open strProduct, Conn, adOpenKeyset, adLockReadOnly, adCmdText
While Not rstProduct.EOF
Label1.Caption = "正在处理的产品:" & rstProduct.Fields("productdwgcode")
strNotComplete = "select productdwgcode,code,revnumber,filename,filetype,fileremark from documents where (code not in (select code from documents_record where productdwgcode='" & rstProduct.Fields("productdwgcode") & "')) and (productdwgcode='" & rstProduct.Fields("productdwgcode") & "') order by productdwgcode,code,revnumber desc"
rstDocuments.Open strNotComplete, Conn, adOpenKeyset, adLockReadOnly, adCmdText
strTemp = ""
While Not rstDocuments.EOF
If Right(rstDocuments.Fields("filename"), 4) = ".DWG" Or Right(rstDocuments.Fields("filename"), 4) = ".dwg" Then
If strTemp <> rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code") Then
Label3.Caption = "正在下载新图纸:" & rstDocuments.Fields("filename")
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True Then

Conn.Execute "insert into documents_record (productdwgcode,code,filename,filetype,fileremark,revnumber) values('" & rstDocuments.Fields("productdwgcode") & "','" & rstDocuments.Fields("code") & _
"','" & rstDocuments.Fields("filename") & "','" & rstDocuments.Fields("filetype") & "','" & rstDocuments.Fields("fileremark") & "','" & rstDocuments.Fields("revnumber") & "')"
End If
strTemp = rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code")
End If
End If
rstDocuments.MoveNext
Wend
rstDocuments.Close
rstProduct.MoveNext
Wend
rstProduct.Close
Set rstProduct = Nothing

''从未下载的
strNew = "select distinct productdwgcode from documents where productdwgcode not in (select distinct productdwgcode from documents_record)"
rstNew.Open strNew, Conn, adOpenKeyset, adLockReadOnly, adCmdText
i = 1
While Not rstNew.EOF
Label1.Caption = "正在处理的产品:" & rstNew.Fields("productdwgcode")
Label3.Caption = "还有" & rstNew.RecordCount & "个产品未下载,正在处理第" & i & "个产品!"
If CreateFolder(rstNew.Fields("productdwgcode")) = True Then
strDocuments = "select productdwgcode,code,revnumber,filename,filetype,fileremark from documents where productdwgcode='" & rstNew.Fields("productdwgcode") & "'order by productdwgcode,code,revnumber desc"
rstDocuments.Open strDocuments, Conn, adOpenKeyset, adLockReadOnly, adCmdText
strTemp = ""
While Not rstDocuments.EOF
If Right(rstDocuments.Fields("filename"), 4) = ".DWG" Or Right(rstDocuments.Fields("filename"), 4) = ".dwg" Then
If strTemp <> rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code") Then
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True Then
Conn.Execute "insert into documents_record (productdwgcode,code,filename,filetype,fileremark,revnumber) values('" & rstDocuments.Fields("productdwgcode") & "','" & rstDocuments.Fields("code") & _
"','" & rstDocuments.Fields("filename") & "','" & rstDocuments.Fields("filetype") & "','" & rstDocuments.Fields("fileremark") & "','" & rstDocuments.Fields("revnumber") & "')"
End If
strTemp = rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code")
End If
End If
rstDocuments.MoveNext
Wend
rstDocuments.Close
End If
i = i + 1
rstNew.MoveNext
Wend
Label1.Caption = "下载完毕!"
Label3.Caption = "所有产品图纸下载完毕!"
txtLog.Text = txtLog.Text & "所有产品图纸下载完毕!" & Chr(13) + Chr(10)
Set rstDocuments = Nothing
rstNew.Close
Set rstNew = Nothing
End If
2006-03-14 19:20
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 
新手可怜可怜吧?
2006-03-14 19:21
kfp_kaka
Rank: 4
等 级:贵宾
威 望:13
帖 子:353
专家分:0
注 册:2006-1-12
收藏
得分:0 

说说你是那里不懂,不会要我们这段代码一句一句的解释吧?


爱一个人不一定要拥有她 拥有一个人就一定要好好的爱她
2006-03-15 09:38
xu_mars
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-3-14
收藏
得分:0 
Dim rstProduct As New ADODB.Recordset( New ADODB.Recordset这个是什么数据类型?)
rstRecord.Open strDocRecord, Conn, adOpenKeyset, adLockReadOnly, adCmdText(不明白)
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True (指2个code相等?)
Conn.Execute "insert into documents_record .....(这段话不理解)
2006-03-15 10:17
kfp_kaka
Rank: 4
等 级:贵宾
威 望:13
帖 子:353
专家分:0
注 册:2006-1-12
收藏
得分:0 
Dim rstProduct As New ADODB.Recordset
这句是创建一个数据集对象
rstRecord.Open strDocRecord, Conn, adOpenKeyset, adLockReadOnly, adCmdText
这句是执行命令,把结果储存在记录集中
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True
调用GetFromFTP函数,这个函数应该是作者自己定义的吧,我不知道这个函数,呵呵,不好意思,解释不到给你听。
Conn.Execute "insert into documents_record .....(这段话不理解)
这句也是执行命令

爱一个人不一定要拥有她 拥有一个人就一定要好好的爱她
2006-03-15 10:41
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 

我也不知道啊
这是个在数据库下载图纸的代码
前这只是中间下载部分
我从来没学过它
现在左看右看看不懂
忘哥哥们帮帮忙啊
指点的越多越好啊
我在这先谢咯哦

2006-03-19 14:35
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 
先帮我解释一下下面这些代码是什么意思吧








While Not rstProduct.EOF
Label1.Caption = "正在处理的产品:" & rstProduct.Fields("productdwgcode")
Label3.Caption = "共有" & rstProduct.RecordCount & "个产品,正在处理第" & i & "个产品!"
If CreateFolder(rstProduct.Fields("productdwgcode")) = True Then
strDocuments = "select productdwgcode,code,revnumber,filename,filetype,fileremark from documents where productdwgcode='" & rstProduct.Fields("productdwgcode") & "'order by productdwgcode,code,revnumber desc"
rstDocuments.Open strDocuments, Conn, adOpenKeyset, adLockReadOnly, adCmdText
strTemp = ""
While Not rstDocuments.EOF
If Right(rstDocuments.Fields("filename"), 4) = ".DWG" Or Right(rstDocuments.Fields("filename"), 4) = ".dwg" Then
If strTemp <> rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code") Then
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True Then
Conn.Execute "insert into documents_record (productdwgcode,code,filename,filetype,fileremark,revnumber) values('" & rstDocuments.Fields("productdwgcode") & "','" & rstDocuments.Fields("code") & _
"','" & rstDocuments.Fields("filename") & "','" & rstDocuments.Fields("filetype") & "','" & rstDocuments.Fields("fileremark") & "','" & rstDocuments.Fields("revnumber") & "')"
End If
strTemp = rstDocuments.Fields("productdwgcode") & rstDocuments.Fields("code")
End If
End If
rstDocuments.MoveNext
Wend
rstDocuments.Close
Set rstDocuments = Nothing
End If
i = i + 1
rstProduct.MoveNext
Wend
Label1.Caption = "下载完毕!"
Label3.Caption = "所有产品图纸下载完毕!"
txtLog.Text = txtLog.Text & "所有产品图纸下载完毕!" & Chr(13) + Chr(10)
rstProduct.Close
Set rstProduct = Nothing
rstRecord.Close
Set rstRecord = Nothing
2006-03-19 14:40
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 
2006-03-19 14:41
along2117
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-3-14
收藏
得分:0 
If GetFromFTP(rstDocuments.Fields("productdwgcode"), rstDocuments.Fields("code")) = True
调用GetFromFTP函数,好象是用FTP形式下载图纸的吧
后面好象定义了GetFromFTP函数,
谢谢大侠门指点啊
我很急
能不能给我看看啊
会的能不能留个QQ交个朋友啊
2006-03-19 14:51
快速回复:[求助]VB程序代码分析!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027183 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved