VBIDE.VBE的应用

connect.dsr

Public VBInstance             As VBIDE.VBE

sub show

    Set Main_Form.VBInstance = VBInstance
    Set Main_Form.Connect = Me

    '自動試験プロジェクトパース名の取得
    tmpStr = VBInstance.VBProjects.Item(PRJTESTAUTO).FileName

end sub 

工程初始化的时候.....

 '==================================================
'
METHOD:    PrjAutoTest_Initialize
'
SUMMARY:  自動試験の工事の初期化
'
PARAMETER: strname As String   仕向けとテストケースの情報
'
RETURN:    true :初期化成功
'
           false:初期化失敗
'
==================================================
Public Function PrjAutoTest_Initialize(strname As StringAs Boolean
On Error GoTo ErrHandler
    
Dim objVBComponent As VBComponent
    
Dim fso As FileSystemObject
    
Dim count As Integer
    
Dim lineP0 As Long
    
Dim lineP1 As Long
    
Dim lineP2 As Long
    
Dim lineP3 As Long
    
Dim lineP4 As Long
    
Dim lineP5 As Long
    
Dim lineP6 As Long
    
Dim i As Integer
    
Dim j As Integer
    
Dim strTemp As String
    
Dim tmpStr As String
    
    
Set fso = CreateObject("Scripting.FileSystemObject")
    
'自動試験プロジェクトパース名の取得
    tmpStr = VBInstance.VBProjects.Item(PRJTESTAUTO).FileName
    path 
= getFolderName(tmpStr)
    count 
= VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count
    
    
If fso.FileExists(path & LOG_VHDL2VB) Then
        
'転換したモジュールの情報をファイルに記憶する
        Open path & LOG_VHDL2VB For Input As #1
            
Do While Not EOF(1)
                Line 
Input #1, strTemp
                
Call DelMod(strTemp)
            
Loop
        Close #
1
        
'ログファイルの削除
        Call Kill(path & LOG_VHDL2VB)
    
End If

    
'試験項目一覧名の追加と関連コードの追加、まずマークのサーチを行います
    Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item("basMain")
    lineP0 
= 1
    find 
= objVBComponent.CodeModule.find("@@##$$-0", lineP0, 000)
    
    lineP1 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-1", lineP1, 000)

    lineP2 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-2", lineP2, 000)

    lineP3 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-3", lineP3, 000)
    
    lineP4 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-4", lineP4, 000)

    lineP5 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-5", lineP5, 000)

    lineP6 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-6", lineP6, 000)
    
If Not find Then GoTo ErrHandler
    
    
'既に入っている試験項目の削除する
    For i = lineP0 + 1 To lineP1 - 1
        
If Left(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7= "frmMain" Then
            
Call objVBComponent.CodeModule.ReplaceLine(i, "")
        
End If
    
Next i
    
'既に入っている試験項目の削除する
    For i = lineP1 + 1 To lineP2 - 1
        
If Left(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7= "frmMain" Then
            
Call objVBComponent.CodeModule.ReplaceLine(i, "")
        
End If
    
Next i
    
'既に入っているロードVHDLを削除する
    For i = lineP3 + 1 To lineP4 - 1
        
If Left(Trim(objVBComponent.CodeModule.Lines(i, 1)), 4= "Case" Then
            
Call objVBComponent.CodeModule.ReplaceLine(i, "")
        
End If
    
Next i

    
'既に入っている試験関数を削除する
    For i = lineP5 + 1 To lineP6 - 1
        
If Left(Trim(objVBComponent.CodeModule.Lines(i, 1)), 4= "Case" Then
            
Call objVBComponent.CodeModule.ReplaceLine(i, "")
        
End If
    
Next i
    
    
'自動試験の仕向け情報を追加する
    lineStr = "            frmMain.labCaseName.Caption =""" & strname & """"
    
Call objVBComponent.CodeModule.ReplaceLine(lineP1 - 1, lineStr)
    PrjAutoTest_Initialize 
= True
    
Exit Function
ErrHandler:
    
Call log_Output(path + "" + LOG_COMPILER, "自動試験プロジェクトの初期化する時,エラーが発生しました。")
    PrjAutoTest_Initialize 
= False
End Function

 

删除一个摸块

 

 '==================================================
'
METHOD:    DelMod
'
SUMMARY:  既に入っているモジュール削除する関数
'
PARAMETER: strname As String モジュールの名前
'
RETURN:     true 削除成功
'
               false 削除失敗
'
==================================================
Private Function DelMod(strname As StringAs Boolean
On Error GoTo Error:
Dim count As Integer
Dim i As Integer

    count 
= VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count
    
    
If count > 0 Then
        
For i = 1 To count
            
If VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i).name = strname Then
                
'モジュールの削除
                VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Remove VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i)
            
End If
        
Next i
    
End If
    DelMod 
= True
    
Exit Function
Error:
    DelMod 
= False
End Function

 

转化的一部分代码

 

    'コンパイルしたVBファイルをプロジェクトに追加します。
    Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.AddFile(path & strVhdlpath & ".bas")
    
    
'重複追加名前同じの場合
    count = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count
    
If count > 0 Then
        
For i = 1 To count
            
If VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i).name = "vhdl_" & entity Then
                
Call DelMod("Module1")
                gComplierNGCount 
= gComplierNGCount + 1
                
Call log_Output(path + "" + LOG_COMPILER, shortName & ": Entity名重複。")
                
Exit Sub
            
End If
        
Next i
        objVBComponent.name 
= "vhdl_" & entity
    
End If
        
    
On Error GoTo SkipRet
    
'共通関数かどうかのチェック。共通関数モジュールであれば、メイン関数がないです。
    'この場合、試験項目一覧名の追加と関連コードの追加がいらないです、SkipRetに飛びます。
    lineP0 = objVBComponent.CodeModule.ProcBodyLine("Test_" & entity, vbext_pk_Proc)
    lineP0 
= objVBComponent.CodeModule.ProcBodyLine("Load_" & entity, vbext_pk_Proc)

    
On Error GoTo ErrHandler4
    
'試験項目一覧名の追加と関連コードの追加、まずマークのサーチを行います
    Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item("basMain")
    lineP0 
= 1
    find 
= objVBComponent.CodeModule.find("@@##$$-0", lineP0, 000)

    lineP1 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-1", lineP1, 000)

    lineP2 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-2", lineP2, 000)

    lineP3 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-3", lineP3, 000)
    
    lineP4 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-4", lineP4, 000)

    lineP5 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-5", lineP5, 000)

    lineP6 
= 1
    find 
= find And objVBComponent.CodeModule.find("@@##$$-6", lineP6, 000)
    
'マークのサーチが失敗する場合、エラーメッセージを出して、処理中止。
    If Not find Then GoTo ErrHandler4

    
'既に入っている試験項目の集計
    count = 0
    
For i = lineP1 + 1 To lineP2 - 1
        
If Left(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7= "frmMain" Then
            count 
= count + 1
        
End If
    
Next

    
'コンボボックスに試験項目名の追加
    lineStr = "                Case " & count & ": Test_" & entity
    
Call objVBComponent.CodeModule.InsertLines(lineP6, lineStr)

    
'VHDLスクリプト表示のため、イベント処理コード追加
    lineStr = "                Case " & count & ": Load_" & entity
    
Call objVBComponent.CodeModule.InsertLines(lineP4, lineStr)

    
'自動試験を行うため、イベント処理コード追加
    lineStr = "            frmMain.Combo1.AddItem """ & shortName & """"
    
Call objVBComponent.CodeModule.InsertLines(lineP2 - count, lineStr)

    
'転換したモジュールの情報をファイルに記憶する
    Open path & LOG_VHDL2VB For Append As #1
           
Print #1"vhdl_" & entity
    Close #
1
    gComplierOKCount 
= gComplierOKCount + 1
    
Call log_Output(path + "" + LOG_COMPILER, shortName & ": OK。")

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

进击的横打

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值