发布网友 发布时间:2022-05-21 18:33
共3个回答
热心网友 时间:2023-11-28 01:00
</I>我最近正在做着方面的工作,我下面的这一段程序希望能对你有帮助,你仔细看一下吧。这只是一段子程序,里面的一些变量都是在它外面定义的,应该可以看出来的。有什么别的问题我们再交流吧。 Private Sub InfoObtain() Set objPartList = objPartLists.Item(1) Set objModelLink = objPartList.ModelLink Set objModelNodes = objModelLink.ModelNodes Set objDocA = objModelLink.ModelDocument 'Set objDocA = objDocD.ModelLinks.Item(1).ModelDocument Set objOccs = objDocA.Occurrences '读取父文件的代号 For lTemp = 1 To objDocA.Properties.Count strTemp = objDocA.Properties.Item(lTemp).Name If strTemp = "Custom" Then For lTemp2 = 1 To objDocA.Properties.Item(lTemp).Count strTemp2 = objDocA.Properties.Item(lTemp).Item(lTemp2).Name If strTemp2 = "代 号" Then strPaName = objDocA.Properties.Item(lTemp).Item(lTemp2).Value Exit For Else End If Next lTemp2 End If Next lTemp Text1.Text = strPaName '删除数据表中原有的数据 strSQL = "Select * From ModelNode" Set RecSet = db.OpenRecordset(strSQL) If RecSet.RecordCount > 0 Then RecSet.MoveLast End If For lTemp = 1 To RecSet.RecordCount RecSet.MoveFirst RecSet.Delete Next lTemp '******************************************** '添加第一条记录 Set objModelNode = objModelNodes.Item(1) For lTemp2 = 1 To objOccs.Count Set objOcc = objOccs.Item(lTemp2) If objOcc.OccurrenceFileName = objModelNode.FileName Then Set obj1 = objOcc.OccurrenceDocument strTemp = obj1.Name Exit For Else End If Next lTemp2 Set objFlds = RecSet.Fields RecSet.AddNew objFlds.Item(1).Value = objModelNode.ItemNumber objFlds.Item(2).Value = objModelNode.ModelType objFlds.Item(3).Value = objModelNode.ModelType objFlds.Item(4).Value = objModelNode.FileName objFlds.Item(5).Value = strTemp RecSet.Update '添加第一条记录 '**************************************************** '******************************************** '添加剩余的记录 For lTemp = 2 To objModelNodes.Count bTemp = True 'bTemp为标志变量,用以区别当前记录是否已经存在于数据表 Set RecSet = db.OpenRecordset(strSQL) RecSet.MoveLast lTemp3 = RecSet.RecordCount RecSet.MoveFirst Set objModelNode = objModelNodes.Item(lTemp) For lTemp2 = 1 To lTemp3 Set objFlds = RecSet.Fields If objModelNode.FileName = objFlds.Item(4).Value Then bTemp = False Exit For Else RecSet.MoveNext End If Next lTemp2 If bTemp Then 'Serach for every filename For lTemp2 = 1 To objOccs.Count Set objOcc = objOccs.Item(lTemp2) If objOcc.OccurrenceFileName = objModelNode.FileName Then Set obj1 = objOcc.OccurrenceDocument strTemp = obj1.Name Exit For Else End If Next lTemp2 RecSet.AddNew objFlds.Item(1).Value = objModelNode.ItemNumber objFlds.Item(2).Value = objModelNode.ModelType objFlds.Item(3).Value = objModelNode.ModelType objFlds.Item(4).Value = objModelNode.FileName objFlds.Item(5).Value = strTemp RecSet.Update Else End If Next lTemp End Sub热心网友 时间:2023-11-28 01:00
Dim lists As ObjectDim list As ObjectDim strList As StringOn Error Resume NextSet objApp = GetObject(, "SolidEdge.Application")If Err ThenErr.ClearSet objApp = CreateObject("SolidEdge.Application")objApp.DisplayFullScreen = 1objApp.Visible = TrueEnd IfobjApp.Visible = FalseSet objDocuments = objApp.Documents'Open an existing fileCall objDocuments.Open(FileName:=App.Path & "\****.par")Set objDoc = objApp.ActiveDocumentSet objVariables = objDoc.VariablesList1.ClearList2.Clear'遍历以“p”打头的变量名信息,并将名称和数值显示到列表框中Set lists = objVariables.Query("p*")For Each list In listsstrList = objVariables.GetName(list)List1.AddItem (strList)strList = list.ValueList2.AddItem (strList * 1000)Next'遍历以“r”打头的变量名信息,并将名称和数值显示到列表框中Set lists = objVariables.Query("r*")For Each list In listsstrList = objVariables.GetName(list)List1.AddItem (strList)strList = list.ValueList2.AddItem (strList * 1000)NextSet lists = NothingSet list = Nothing热心网友 时间:2023-11-28 01:00
在本网第二页我回复的用“vb二次开发中如何获得零件的数量、材料”有对PartList的开发程式,不知能不能帮你。 http://www.3dst.com/thread-9655-1-2.html