VB.NET jsscript和vbscript脚本之间数据传递操作

vbscript脚本示例:

jsscript脚本示例:

jsscript和vbscript脚本的数据传递的方法是一样的;只是脚本里面的对象稍有不同,需要深入学习请自行百度!

操作vbscript脚本vb.net源码示例:

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim vbs As Object
        Dim code, TMP, DDB, CB, ZYCB, BB, LT, GB As String
        '------------------------------------------
        code = "dim C,K,H " & vbCrLf &
            "C = " & Val(TextBox1.Text) & vbCrLf &
            "K = " & Val(TextBox2.Text) & vbCrLf &
            "H = " & Val(TextBox3.Text) & vbCrLf
        vbs = CreateObject("MSScriptControl.ScriptControl")
        vbs.Language = "VBScript"
        vbs.State = 1
        vbs.allowui = True
        On Error GoTo Err
        vbs.AddCode(code)
        vbs.ExecuteStatement(RichTextBox1.Text)
        '-------------------------
        DDB = vbs.CodeObject.DDB
        CB = vbs.CodeObject.CB
        ZYCB = vbs.CodeObject.ZYCB
        BB = vbs.CodeObject.BB
        LT = vbs.CodeObject.LT
        GB = vbs.CodeObject.GB
        TMP = "-------------BOM---------" & vbCrLf &
              "顶 底 板:" & DDB & vbCrLf &
              "层    板:" & CB & vbCrLf &
              "左右侧板:" & ZYCB & vbCrLf &
              "背    板:" & BB & vbCrLf &
              "拉    条:" & LT & vbCrLf &
              "挂    板:" & GB & vbCrLf & vbCrLf
        RichTextBox2.AppendText(TMP)
Err:
        RichTextBox3.Text = "错误代号:" & vbs.Error.number & vbCrLf &
               "错误信息:" & vbs.Error.Description & vbCrLf &
               "错误行号:" & vbs.Error.Line & vbCrLf &
               "错误列号:" & vbs.Error.Column
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Form2.Show()
    End Sub
End Class

操作jsscript脚本vb.net源码示例(其实vbscript脚本一样的,不同的只是脚本语言):

Public Class Form2
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim JS As Object
        Dim code, TMP, DDB, CB, ZYCB, BB, LT, GB As String
        code = "var C;var K; var H; " & vbCrLf &
            "C = " & Val(TextBox1.Text) & ";" & vbCrLf &
            "K = " & Val(TextBox2.Text) & ";" & vbCrLf &
            "H = " & Val(TextBox3.Text) & ";" & vbCrLf
        JS = CreateObject("MSScriptControl.ScriptControl")
        JS.Language = "JScript"
        JS.AddCode(code)
        JS.State = 1
        JS.allowui = True
        On Error GoTo err
        JS.ExecuteStatement(RichTextBox1.Text)
        DDB = JS.CodeObject.DDB
        CB = JS.CodeObject.CB
        ZYCB = JS.CodeObject.ZYCB
        BB = JS.CodeObject.BB
        LT = JS.CodeObject.LT
        GB = JS.CodeObject.GB
        TMP = "------------J01BOM---------" & vbCrLf &
              "顶 底 板:" & DDB & vbCrLf &
              "层    板:" & CB & vbCrLf &
              "左右侧板:" & ZYCB & vbCrLf &
              "背    板:" & BB & vbCrLf &
              "拉    条:" & LT & vbCrLf &
              "挂    板:" & GB & vbCrLf & vbCrLf
        RichTextBox2.AppendText(TMP)
Err:
        RichTextBox3.Text = "错误代号:" & JS.Error.number & vbCrLf &
               "错误信息:" & JS.Error.Description & vbCrLf &
               "错误行号:" & JS.Error.Line & vbCrLf &
               "错误列号:" & JS.Error.Column
    End Sub
End Class

vbscript脚本示例:

DIM BJC,BJK,BJH,DBC,DBK,DBH,BH
DIM CBC,CBK,CBH,BBH,ZCBC,ZCBK
DIM ZCBH,BBC,BBK,LTC,LTK,LTH
DIM GBC,GBK,GBH
DIM DDB,CB,ZYCB,BB,LT,GB
BH=15
BBH=5
BJC=C
BJK=K
BJH=H

DBC=BJC-BH*2
DBK=BJK
DBH=BH
DDB=DBC & "x" & DBK & "x" & BH & " -2PCS"

CBC=BJC-BH*2
CBK=BJK-BH-BBH-2-1
CBH=BH
CB=CBC & "x" & CBK &  "x" & CBH & " -2PCS"

ZCBC=BJH
ZCBK=BJK
ZCBH=BH
ZYCB=ZCBC & "x" & BJK & "x" & ZCBH & " -2PCS"

BBC=BJH-BH*2-150+11
BBK=BJC-BH*2+11
BBH=BBH
BB=BBC & "x" & BBK & "x" & BBH & " -2PCS"

LTC=BJC-BH*2
LTK=80
LTH=BH
LT=LTC & "x" & LTK & "x" & LTH & " -1PCS"

GBC=BJC-BH*2-5
GBK=80
GBH=BH
GB=GBC & "x" & GBK & "x" & GBH & " -1PCS"

jsscript脚本示例:

var BJC=C;var BJK=K;var BJH=H;var BH;var BBH;

BH=15;
BBH=5;
BJC=C;
BJK=K;
BJH=H;
var DBC;var DBK;var DBH;var DDB;

DBC=BJC-BH*2;
DBK=BJK;
DBH=BH;
DDB=DBC + "x" + DBK + "x" + BH + " -2PCS";

var CBC;var CBK;var CBH;var CB;

CBC=BJC-BH*2;
CBK=BJK-BH-BBH-2-1;
CBH=BH;
CB=CBC + "x" + CBK +  "x" + CBH + " -2PCS";

var ZCBC;var ZCBK;var ZCBH;var ZYCB;
ZCBC=BJH;
ZCBK=BJK;
ZCBH=BH;
ZYCB=ZCBC + "x" + BJK + "x" + ZCBH + " -2PCS";

var BBC;var BBK;var BB;

BBC=BJH-BH*2-150+11;
BBK=BJC-BH*2+11;
BBH=BBH;
BB=BBC + "x" + BBK + "x" + BBH + " -2PCS";

var LTC;var LTK;var LTH;var LT;

LTC=BJC-BH*2;
LTK=80;
LTH=BH;
LT=LTC + "x" + LTK + "x" + LTH + " -1PCS";


var GBC;var GBK;var GBH;var GB;

GBC=BJC-BH*2-5;
GBK=80;
GBH=BH;
GB=GBC + "x" + GBK + "x" + GBH + " -1PCS";

本文分享自微信公众号 - VB小源码(vb_xym)

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2019-03-19

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券