首页 > 编程语言 >lighttools batchmode 批处理vb程序代码

lighttools batchmode 批处理vb程序代码

时间:2023-11-07 11:11:22浏览次数:47  
标签:Dim vb End Sub batchmode lt lstFileOnClosed 程序代码

lighttools 连接代码:

 1 Private m_ltServer As LTAPI
 2 
 3 
 4 
 5 Public Function getLTAPIServer() As LTAPI
 6 If m_ltServer Is Nothing Then
 7     Dim lt As IUnknown
 8     Dim ltLoc As Locator
 9     Dim cmd As String
10     Set ltLoc = CreateObject("LTLocator.Locator")
11     ' to get a LightTools Server pointer, you need to know
12     ' the calling server process ID
13     ' if it is passed to this application via command line
14     ' in a shape of "-LTPID1234" (AddIn standard)
15     ' (1234 being hypothetical LightTools Process ID), do this
16     cmd = Command ' get command line
17     ' if command line is in the form of "-LTPID1234" you can
18     ' directly pass it to Locator
19     Set lt = ltLoc.GetLTAPIFromString(cmd)
20     'if the client code knows LT PID somehow, it could use the
21     ' GetLTAPI(pidNumber) interface
22     Set m_ltServer = lt
23     Set ltLoc = Nothing
24 End If
25 
26 Set getLTAPIServer = m_ltServer
27 End Function
28 Sub test2()
29 Dim lt As LTAPI
30 
31 Set lt = getLTAPIServer()
32 lt.Message ("Correct way of connecting to LightTools")
33 End Sub

窗体代码:

Option Explicit
Dim i As Integer
Dim j As Integer
Dim exist As Boolean

Private Sub cmdAddAll_Click()
'添加所有对象至Listbox
On Error Resume Next

For i = 0 To filList.ListCount - 1
    exist = False
    ' 排除重复对象
    For j = 0 To lstFileOnClosed.ListCount - 1
        If lstFileOnClosed.List(j) = DirList.Path & "\" & filList.List(i) Then
            exist = True
            Exit For
        End If
    Next j
    If exist = False Then
        lstFileOnClosed.AddItem DirList.Path & "\" & filList.List(i)
    End If
    
Next i
End Sub

Private Sub cmdAddSelect_Click()
'添加选择的对象至Listbox
On Error Resume Next
For i = 0 To filList.ListCount - 1
    exist = False
     ' 排除重复对象
    If filList.Selected(i) = True Then '判断对象是否被选中
    
        For j = 0 To lstFileOnClosed.ListCount - 1
            If lstFileOnClosed.List(j) = DirList.Path & "\" & filList.List(i) Then
                exist = True
                Exit For
            End If
        Next j
        
        If exist = False Then
        
            lstFileOnClosed.AddItem DirList.Path & "\" & filList.List(i)
        End If
        
    End If
Next i
End Sub

Private Sub cmdRemoveAll_Click()
'从listbox中移出所有的对象
  lstFileOnClosed.Clear
End Sub

Private Sub cmdRemoveSelect_Click()
'从listbox中移出选择的对象
On Error Resume Next
For i = 0 To lstFileOnClosed.ListCount - 1
  If lstFileOnClosed.Selected(i) = True Then
    lstFileOnClosed.RemoveItem (i)
  End If
Next i
End Sub

Private Sub Command1_Click()
'Debug.Print lstFileOnClosed.List(0)
'Debug.Print DirList.Path

Dim i As Integer
Dim sumok As Integer
Dim sumng As Integer
Dim datebegin As Date
Dim dateend As Date
Dim usetime As Date
sumok = 0
sumng = 0

App.OleRequestPendingMsgText = "模拟中,请等待!" '设置程序等待msg
App.OleServerBusyTimeout = 36000000 '设置程序等待时间单位ms,目前未10h
'排除未选择模拟文件的情况
If batchmode.lstFileOnClosed.ListCount = 0 Then
    batchmode.Text1.Text = "请选择要模拟的文件" & vbCrLf
    Exit Sub
End If
batchmode.Text1.Text = "模拟过程中请不要点击此窗体" & vbCrLf
For i = 0 To batchmode.lstFileOnClosed.ListCount - 1
    Dim lt As New LTAPI
    Dim FName As String
    Dim status As String
    datebegin = Now
    FName = batchmode.lstFileOnClosed.List(i)
    lt.SetOption "ShowDialogs", 0
    lt.SetOption "ShowFileDialogBox", 0
    lt.cmd "\VConsole" 'Note that this is case sensitive!
    lt.cmd "Open " & lt.Str(FName)
    lt.SetOption "ShowDialogs", 1
    lt.SetOption "ShowFileDialogBox", 1
    lt.cmd "\V3D"
    status = lt.cmd("BeginAllSimulations")
    dateend = Now
    usetime = dateend - datebegin
    If status = 0 Then
        batchmode.Text1.Text = batchmode.Text1.Text + " sim OK 用时" & usetime & " " & FName & vbCrLf
        sumok = sumok + 1
    Else
        batchmode.Text1.Text = batchmode.Text1.Text + " sim NG;错误代码:" & status & "用时" & usetime & " " & FName & vbCrLf
        sumng = sumng + 1
    End If
    lt.cmd "save"
    lt.cmd "close"

Next i
batchmode.Text1.Text = batchmode.Text1.Text + "所有模拟已经完成,其中" & sumok & "个模拟OK;其中" & sumng & "个模拟NG。"

End Sub

Private Sub DirList_Change()
'  更新文件列表框,使它与目录列表框保持同步。
    filList.Path = DirList.Path
End Sub
   
Private Sub DirList_LostFocus()
    DirList.Path = DirList.List(DirList.ListIndex)
End Sub
   
Private Sub DrvList_Change()
    On Error GoTo DriveHandler
    DirList.Path = DrvList.Drive
    Exit Sub
   
DriveHandler:
   DrvList.Drive = DirList.Path
    Exit Sub
  End Sub


Private Sub Form_Load()
'初始化FileListbox的格式及Drivelistbox的驱动盘
  filList.Pattern = "*.lts"
  DrvList.Drive = App.Path
  batchmode.Text1.Text = "欢迎使用此插件!" & vbCrLf
End Sub

然后生成为EXE格式,就可以进行使用。

 

标签:Dim,vb,End,Sub,batchmode,lt,lstFileOnClosed,程序代码
From: https://www.cnblogs.com/huazhonglou/p/17814584.html

相关文章

  • 没有文件扩展“.vbs”的脚本引擎的解决方案
    当你在运行一些基于VBS脚本语言的文件时,系统可能报错。这时候可能是你的VBS脚本服务在注册表中出错了,原因可能是卸载或安装一些代码不规范的程序引起的。这里给出无法找到脚本引擎"vbscript"的解决方法:1)找到文件:C:\WINDOWS\inf\wsh.inf,右键“安装”;2)开始→运行行里输入......
  • EXCEL VBA自动设置坐标轴上下限
    下面的效果图展示了,将图表Y轴的的最大/最小值进行了动态设置Y轴最大值为:数据源最大值+2Y轴最小值为:数据源最小值-2通过上面的方法,数据源变化,那么Y轴的上下限也会自动变化 代码部分关键字MinimumScale设置Y轴的最小值关键字MaximumScale设置Y轴的最小值通过Max与Min......
  • win bat 脚本 - 使用vbs实现 带参数 创建桌面快捷方式 - chrome多版本安装为例子
    官网下载win安装包,地址https://www.chromedownloads.net/chrome64win-canary/解压win安装chrome文件,得到这个文件夹 bat脚本放在同一个目录下安装脚本如下【可用的哦,这是带参数的】@echooff::快捷方式名称set"name=chrome快捷桌面启动入口"setroot=%~dp0se......
  • VbScript脚本Request获取RFID读卡器以HTTP提交的访问文件中的参数Response回应驱动读
    本示例使用的设备:<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%><%Functionbin2str(bindata)DimrsStream,strlsSetrsStream=Server.CreateObject("ADODB.Stream")rsStream.Type=2rsStream.OpenrsStream.Wri......
  • 学习笔记432—VBM_DARTEL算法对灰质变化的计算
    VBM_DARTEL算法对灰质变化的计算根据一些文献得知,VBM目前比较新的算法是DARTEL算法,这一算法被集成在SPM里,这里记录一下做法。VBM是对T1像进行分割得到灰质等。所以要有结构T1加权像数据。整个流程应该是这样:1.手动调整前联合(AC)首先就是需要我们自己手动调整一下结构像,打开SPM,sp......
  • vb日期操作
    字符串与日期相互转换VB使用CDate函数将字符串转换成Date类型s1="2000-01-01"d1=Cdate(s1) VB使用 format函数将日期转换成字符串类型d1=format(now,"yyyy-MM-dd") 获取年月日时分秒获取一个日期的年月日时分秒,假设变量d1为Date类型Year(d1)获取年份M......
  • vba 处理word 的一些代码:修改公式(1--1)为(1-1)
    SubConvertSpecificEquationsToText()DimoEqAsOMathDimeqTextAsStringDimregExAsObjectSetregEx=CreateObject("VBScript.RegExp")'DefinetheregularexpressionpatternregEx.Pattern="(\d.?\d)"'Patternfor(di......
  • VBA获取文件夹下所有文件名或者文件夹名
    VBA获取文件夹下所有文件名或者文件夹名1,新建excel宏2,在sheet中添加宏执行按钮3,设置按钮执行的代码名VBA代码如下:`点击查看代码'选择文件按钮程序PrivateSubCommandButton1_Click()Application.ScreenUpdating=FalseCallChooseApplication.ScreenUpdatin......
  • 金蝶KIS VB插件 老单据如何插入多行值,老单获取基础资料内码、代码、名称
    转自:https://blog.csdn.net/ssyyll/article/details/16804273WhileNotrs.EOF '填充对应的行 Withm_BillTransfer '如果超过两行以上的值,需要先用 .BillForm.InsertRow '插入一行 .SetGridTextLRow,dicFieldEntry("FItemID"),rs("FNumber") .SetGridText......
  • (512M位)W25Q512JVFIM、W25Q512JVBIQ、W25Q512JVFIQ、W25Q512JVEIQ串行闪存提供更高的灵
    描述W25Q512JV(512M位)串行闪存为空间、引脚和电源有限的系统提供了存储解决方案。25Q系列提供超越普通串行闪存设备的灵活性和性能。它们非常适合将代码映射到RAM、直接从双通道/四通道SPI(XIP)执行代码以及存储语音、文本和数据。该器件采用2.7V至3.6V单电源供电,省电模式下功耗低至......