VB script 入门

VB script 入门,第1张

概述这里简单介绍下vb script 脚本的基本语法: 后面可以参考这个例子: Sub 创建任务脚本_Click()Dim Line As String Dim ColumnStr As String Dim Substr As String Dim Str, Val, n max_line = 20000 Set fs = CreateObject("Scri

这里简单介绍下vb script 脚本的基本语法:

后面可以参考这个例子:

Sub 创建任务脚本_Click()Dim line As String  Dim ColumnStr As String  Dim Substr As String  Dim Str,Val,n      max_line = 20000    Set fs = CreateObject("Scripting.fileSystemObject")    sfilename = ThisWorkbook.Path + "\..\..\Sources\sql\output.sql"  Set fhandle = fs.CreateTextfile(sfilename,True)    i = 1  For i = 1 To 200  '显示修改历史记录预设200行    If (Cells(i,1) = "修改历史") And UCase(Cells(i,2)) = "BEGIN" Then        j = i + 1        fhandle.Writeline ("-- 修改历史:")        While Not (Cells(j,1) = "修改历史" And UCase(Cells(j,2)) = "END")            fhandle.Writeline ("-- " & Cells(j,1) & " -" & Cells(j,2) & " -" & Cells(j,3) & " -" & Cells(j,4))            j = j + 1        Wend        Exit For    End If  Next    '1.定位到第一条数据所在行数  menu_start = 0  For i = 1 To max_line    If Cells(i,2) = "交易市场" Then      menu_start = i + 1      Exit For    End If  Next    If menu_start = 0 Then    Exit Sub  End If   fhandle.Writeline ("                                                       ")  fhandle.Writeline ("                                                       ")          '3.生成任务脚本    For i = menu_start To max_line      If Cells(i,2) = "" Then         Exit For      End If        fhandle.Writeline ("--" & Cells(i,15) & " start")        fhandle.Writeline ("declare")        fhandle.Writeline ("    iCountNum number;")        fhandle.Writeline ("begin")        fhandle.Writeline ("    iCountNum := 0;")                line = "    select count(*) into iCountNum from TCONVERTSET where vc_module = '" & Cells(i,7) & "' and vc_function = '" & Cells(i,8) & "';"        fhandle.Writeline (line)        fhandle.Writeline ("    if (iCountNum = 0) then")               line = "        insert into TCONVERTSET (L_SERIAL_NO,L_OPERATOR_NO,C_MARKET_NO,C_CONVERT_TYPE,L_THREAD_COUNT,L_BEGIN_TIME,L_END_TIME,VC_MODulE,VC_FUNCTION,C_CONVERT_STATUS,L_PRIORITY_LEVEL,VC_REMARKS,VC_INIT_FUNCTION,C_RUN_ONCE,C_VERSION )"        fhandle.Writeline (line)        line = "        values ( SeqConvertSetNo.nextval,1000,'" & Cells(i,2) & "',3) & "'," & Cells(i,4) & ",5) & ",6) & ",7) & "',8) & "',9) & "',10) & ",11) & "',12) & "',13) & "',14) & "');"        fhandle.Writeline (line)                fhandle.Writeline ("    end if; ")        fhandle.Writeline ("end; ")        fhandle.Writeline ("/ ")        fhandle.Writeline ("")            ' End FOR    Next     fhandle.Writeline ("commit; ")   fhandle.Close   MsgBox "任务脚本创建成功!" & Chr(10) & "文件名:" & sfilenameEnd Sub
总结

以上是内存溢出为你收集整理的VB script 入门全部内容,希望文章能够帮你解决VB script 入门所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1266459.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存