我在.NET中编写了一个DLL,我想在VBScript中访问它.我不想将它添加到汇编目录中.
有没有办法指出DLL并创建它的实例?
我想以同步方式从vbscript执行.NET dll文件 - 这可能吗?如果是,是否可以执行GAC程序集?
谢谢,Ofer
目前我必须处理用VB编写的遗留系统.我对VB和ASP不太满意,所以我决定用JScript编写这个系统的新代码.
但是,这两种语言之间的互操作性存在一些问题:即,当我试图调用在<script language="vbscript">tag中声明的某个函数时,它会因" Object expected "错误而失败(如果页面语言是VBScript),反之亦然.
即,以下代码:
inc.asp
<script language="vbscript" runat="server">
Sub VBTestFunction(Message)
Response.Write "VBTestFunction: " & Message
End Sub
</script>
<script language="javascript" runat="server">
function JSTestFunction(Message) {
Response.Write("JSTestFunction: " + Message);
}
</script>
Run Code Online (Sandbox Code Playgroud)
testjs.asp
<%@ Language="JavaScript" %>
<!-- #include file="inc.asp"-->
<script language="javascript" runat="server">
VBTestFunction("from javascript");
JSTestFunction("from javascript");
</script>
<script language="vbscript" runat="server">
Call VBTestFunction("from vbscript")
Call JSTestFunction("from vbscript")
</script>
Run Code Online (Sandbox Code Playgroud)
失败,出现以下错误:
VBTestFunction: from vbscript
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'JSTestFunction'
/test.asp, line 9
Run Code Online (Sandbox Code Playgroud)
(如果我对特定行进行评论,其他三个语句将正常工作); 将页面语言设置为VBScript
<%@ Language="VBScript" %> …Run Code Online (Sandbox Code Playgroud) 从bat文件运行vbs脚本时,有时会在头文件输出文件中写入
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation 1996-2001. Tous droits r‚serv‚s
example: cscript myvbs.vbs file.txt >result.txt
Run Code Online (Sandbox Code Playgroud)
我知道在输出文件上做了更多+2,我可以忽略它.毫无疑问,我想知道是否有可能以不同的方式做到这一点.
先感谢您
我正在尝试使用getref从与测试关联的函数库中调用函数.我的代码 -
在行动1
str = "sample"
msg = "hi"
x = GetRef("Function_"&str)(msg)
msgbox x
Run Code Online (Sandbox Code Playgroud)
在函数库中,
Function Function_sample(strMsg)
Function_sample = strMsg
End Function
Run Code Online (Sandbox Code Playgroud)
我收到了错误 -
"无效的过程调用或参数."
但是如果函数放在同一个动作中,它可以正常工作.如何调用函数库中的函数(带参数),从变量中获取函数名?
我有一个脚本打开excel文件并运行宏,然后退出该文件.由于文件处于只读模式,并且脚本对文件进行临时更改,因此当脚本调用myExcelWorker.Quit()excel询问我是否要保存更改时,必须单击"否".有没有办法退出程序并跳过此框?
' Create a WshShell to get the current directory
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
' Create an Excel instance
Dim myExcelWorker
Set myExcelWorker = CreateObject("Excel.Application")
myExcelWorker.Visible = True
' Tell Excel what the current working directory is
' (otherwise it can't find the files)
Dim strSaveDefaultPath
Dim strPath
strSaveDefaultPath = myExcelWorker.DefaultFilePath
strPath = WshShell.CurrentDirectory
myExcelWorker.DefaultFilePath = strPath
' Open the Workbook specified on the command-line
Dim oWorkBook
Dim strWorkerWB
strWorkerWB = strPath & "\BugHistogram_v2.xlsm"
Set oWorkBook …Run Code Online (Sandbox Code Playgroud) 我有3个脚本,其中所有脚本必须以正确的顺序重复运行.
下面的脚本是第3个脚本.每当我运行它时,它都会以"输入文件末尾"错误结束.我已经尝试了几次修改,它总是以这种方式结束.
我对第三个脚本的想法是第二个文件的Differences.txt输出仍然需要从第一个脚本运行进程,所以我只是删除原始输入文件并将其重命名为新的输出文件.但是,我还必须跟踪已经完成的过程,因此我必须将它们列出/附加到另一个文本文件.
在此先感谢您的帮助.
Option Explicit
Dim objFso
Dim Fso
Dim firstfile,secondfile,file,fileText
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("Machines.ini") Then objFSO.DeleteFile("Machines.ini")
Set Fso = WScript.CreateObject("Scripting.FileSystemObject")
Fso.MoveFile "Differences.txt", "Machines.ini"
firstfile="Notified.txt"
secondfile="Notified-all.txt"
Set fso=CreateObject("Scripting.FileSystemObject")
Set file=fso.OpenTextFile(firstfile)
fileText = fileText & file.ReadAll() & vbCrLf
file.Close
Set file=fso.OpenTextFile(secondfile)
fileText=filetext & file.ReadAll()
file.Close
set file=fso.CreateTextFile(secondfile,true)
file.Write fileText
file.close
Run Code Online (Sandbox Code Playgroud) 我有一个Excel VBA程序,它循环遍历数据表中的每一行数据.
我的目标是在布尔值bFound设置为时退出while循环True.
我认为我的条件"或bFound = True"可能不正确.
bFound = False
While Sheets("Data").Cells(iRow, 1) <> "" Or bFound = True
If Sheets("Data").Cells(iRow, 11) = Sheets("Data2").Cells(iRow, 1) Then
bFound = True
End If
iRow = iRow + 1
Wend
'exit loop after the boolean=true
Run Code Online (Sandbox Code Playgroud) 据我所知,Microsoft在2011年决定弃用OLE DB,并且除了SQL Native Client V11之外不会发生新的驱动程序或维护.将来你应该使用基于ODBC的驱动程序 - http://weblogs.sqlteam.com/dang/archive/2011/09/04/rip-ole-db.aspx
最新的ODBC驱动程序是2016年7月25日发布的"用于SQL Server的Microsoft ODBC驱动程序13" - https://www.microsoft.com/en-us/download/details.aspx?id=50420
Native Client V9,10,11和Microsoft ODBC驱动程序SQL Server V11和13中的ODBC驱动程序都可以在与SQL服务器交互的经典ASP代码中工作(我使用的是SQL 2012),除了一个问题 - nText和Nvarchar(max).
它们只是返回空白 - 我已经看到解决方案说你应该首先读入局部变量而不是直接寻址记录集,例如varStr = rs("LargeText"),但这对我不起作用.还有其他提到使用get chunk等.
但我很高兴使用Native Client V9(Provider = SQLNCLI),它与这些数据类型完美配合.
所以,我的问题是:
有没有让ODBC驱动程序使用nText/Nvarchar(max)数据类型?
在OLEDB上使用ODBC有什么好处吗?
我是否必须在某个阶段升级到ODBC以便将来连接到SQL服务器,即SQL 2014/2016?
换句话说,我可以继续使用OLEDB吗?
好的,Lankymart - 我会用这样的东西:
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Driver={SQL Server Native Client 11.0};Server=*Yourserver*;Database=*YourDatabase*;User ID=*YourUserid*;Password=*YourPassword*;"
'oConn.Open "Provider=SQLNCLI11;Server=*YourServer*; Database=*YourDatabase*;User ID=*YourUserID*;Password=*YourPassword*;"
set view=oConn.Execute("SELECT [PText] FROM [TextTest]")
ttext=view("PText")
response.write(ttext)
view.Close
set view = Nothing
oConn.Close
set oConn = Nothing
Run Code Online (Sandbox Code Playgroud)
其中[PText]是SQL中的NVARCHAR(Max)字段.这不能使用本机客户端ODBC({SQL Server Native Client 11.0}),但将使用OLE DB(SQLNCLI11).
vbscript ×10
.net ×2
asp-classic ×2
dll ×2
excel ×2
excel-vba ×2
vba ×2
assemblies ×1
batch-file ×1
com ×1
jscript ×1
qtp ×1