嗨,我正在用下面的代码创建ac#dll
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
namespace imageexport
{
[ComVisible(true)]
public class ExportImage
{
[ComVisible(true)]
public void exportPNG(String pDirectory,String svgFileName,String outputFileName) {
String arguments= pDirectory+"res\\include\\highcharts-convert.js -infile "+pDirectory+"res\\graphs\\"+svgFileName+" -outfile "+pDirectory+"res\\graphs\\"+outputFileName +" -scale 2.5 -width 1088";
/*using (StreamWriter writer = new StreamWriter("c:\\debug.txt", true))
{
writer.WriteLine("pDirectory=" +pDirectory);
writer.WriteLine("arguments="+arguments);
}*/
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = false;
p.StartInfo.FileName = pDirectory+"res\\bin\\phantomjs.exe";
p.StartInfo.Arguments = arguments;
p.Start();
p.WaitForExit();
}
}
}
为了创建DLL,我在VS2005中进行如下配置
Application
Assembly Name - … 编辑:在我将特定的Excel文件或其窗口放到前面之前,我需要检查它是否正在运行/仍然打开.
旧问题:我想在前面设置一个特定的Excel窗口.
使用此VBScript代码,我可以按名称激活一个Excel窗口.但是由于打开了多个Excel窗口,它不再起作用.在这种情况下,它将找不到所需的窗口,并且无法检查它是否打开.所以它总是会说ExcelFileName没有打开.
Set WshShell = WScript.CreateObject ("WScript.Shell")
if WshShell.AppActivate(ExcelFileName) = True then
wscript.echo ExcelFileName & " is opened."
WshShell.sendkeys "%x" 'in Excel 2003 this would had opened the extra-menu-droplist of the menu-bar. Now it just activates Excel.
else
wscript.echo ExcelFileName & " is not open."
End if
Run Code Online (Sandbox Code Playgroud)
如何使其与多个打开的Excel窗口一起使用?
以下代码是一个vb脚本,可将文本从用户输入转换为语音。我希望从txt文件中获取文本。
Dim msg, sapi
msg=InputBox("Hello", "hello")
Set sapi =CreateObject("sapi.spvoice")
sapi.Speak msg
Run Code Online (Sandbox Code Playgroud) 我对如何对对象数组进行for-each循环感到困惑。当前,我的方法以两种方式之一使我出错。for循环执行或因为认为类变量未定义而遇到问题,或者遇到对象类型是非法赋值的问题。
这是我定义的类:
Class url_Link
Public title, link
Public Default Function Init(newTitle, newLink)
title = newTitle
link = newLink
Set Init = Me
End Function
End Class
Run Code Online (Sandbox Code Playgroud)
作为参考,我得到的错误是:
Microsoft VBScript运行时错误'800a01f5'
非法分配:“ url_Link”
行674
使用此代码段:
<% for each x in systemSettingsArray%>
<tr>
<td class='nograph'><A href='<%x.link%>'><%x.title%></a></td>
</tr>
<%next%>
Run Code Online (Sandbox Code Playgroud)
当我更改url_Link为时x,出现此错误:
无效的过程调用或参数“链接”
创建对象并填充数组的代码:
Dim systemSettingsArray(1)
Dim link
Dim arrayCounter
arrayCounter = 0
Set systemSettingsArray(arrayCounter) = (New url_Link)("Account Administration", "Maintenance/Account_Admin.asp")
arrayCounter = arrayCounter + 1
Set systemSettingsArray(arrayCounter) = (New url_Link)("Time Approval", "Maintenance/system_Time_Approval.asp")
Run Code Online (Sandbox Code Playgroud) 我的一个用户有一个'在用户名内,我认为它打破了行上的登录代码tempPassword = Request.Form("UserPassword")
if (Request.Form("Action") = "Login") then
tempUsername=Request.Form("UserName")
tempPassword=Request.Form("UserPassword")
if not (tempUserName = "") and not (tempPassword = "") then
strSQL="SELECT ContactID,Email,Password from Directory WHERE Email='" & tempUsername & "' AND Password='" & tempPassword & "'"
set rsQuery=cn.execute(strSQL)
if not (rsQuery.EOF) then
'-- Login correct, so set session variables
Session("CBWorkUser") = "Yes"
Session("CBWorkUserName") = rsQuery("Email")
Session("CBWorkID") = rsQuery("ContactID")
end if
set rsQuery = nothing
end if
end if
Run Code Online (Sandbox Code Playgroud)
有什么解决方案可以解决这个问题?
我只是想知道是否有可能取消变量.
想象一下,这是我在ASP页面中使用的#include文件
Dim MyVar
MyVar = "Hello World"
Response.write(MyVar)
'From now on I can not use Dim MyVar anymore as it throws an error
'I have tried
MyVar = Nothing
Set MyVar = Nothing
'But again, when you do
Dim MyVar
'It throws an error.
Run Code Online (Sandbox Code Playgroud)
原因是我不能每页多次使用相同的#INCLUDE文件.是的,我喜欢使用Option Explicit,因为它可以帮助我保持代码清洁.
*)编辑:我发现它并不像我想的那么清晰.
想象一下这是一个"include.asp"
<%
Dim A
A=1
Response.Cookie("beer")=A
%>
Run Code Online (Sandbox Code Playgroud)
现在的asp页面:
<!--#include file="include.asp"-->
<%
'Now: I do not see whats in include above and I want to use variable A
Dim A
'And I get …Run Code Online (Sandbox Code Playgroud) 我有一个VBScript创建一个表.它循环遍历数组并将信息插入Word文档中的表中.
'Create new word doc
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = "12"
objSelection.TypeText sFileSelected
objSelection.TypeParagraph()
objSelection.Font.Name = "Verdana"
objSelection.Font.Size = "12"
Set objRange = objSelection.Range
Set objFSO = CreateObject("scripting.filesystemobject")
Set objTF = objFSO.opentextfile(logPathAndFileName)
strAll = objTF.readall
arrVar = Split(strAll, vbNewLine)
numcols = 3
objDoc.Tables.Add objRange, UBound(arrVar) - LBound(arrVar) + 1, numcols
Set objTable = objDoc.Tables(1)
For lngrow = LBound(arrVar) To UBound(arrVar)
If lngrow > 0 Then …Run Code Online (Sandbox Code Playgroud) 正则表达式:
<span style='.+?'>TheTextToFind</span>
Run Code Online (Sandbox Code Playgroud)
HTML:
<span style='font-size:11.0pt;'>DON'T_WANT_THIS_MATCHED <span style='font-size:18.0pt;'>TheTextToFind</span></span>
Run Code Online (Sandbox Code Playgroud)
为什么比赛包括这个?
<span style='font-size:11.0pt;'>DON'T_WANT_THIS_MATCHED
Run Code Online (Sandbox Code Playgroud)
如何在VBScript中编码波纹管条件?
>= 0 [Red] Ex.: {0,1,2,3,4...}
Between -1 and -7 [Yellow] Ex.: {-1,-2,-3,-4,-5,-6,-7} ONLY
Greater or equal than -8 [Green] Ex.: {-8,-9,-10,-11...}
Run Code Online (Sandbox Code Playgroud)
我有以下代码,Mydate是一个有效的日期,Red部分是OK.问题是黄色,我不知道我能不能像你一样做范围.它看起来像是被忽略并且变黄更大的范围.
<%
IF DateDiff("d", MyDate, Now()) >= 0 THEN
%>
[Red]
<%
ELSEIF DateDiff("d", MyDate, Now()) =< -1 OR DateDiff("d", MyDate, Now()) >= -8 THEN
%>
[Yellow]
<%
ELSE
%>
[Green]
<%
END IF
%>
Run Code Online (Sandbox Code Playgroud) 我是VB的新手,遇到了我认为必须是新手的常见错误.我正在尝试使用此代码段将字符串拆分为数组:
Dim myString, myArray
myString = "split-this"
myArray = myString.Split("-")
Run Code Online (Sandbox Code Playgroud)
这给了我错误:
Microsoft VBScript runtime error '800a01a8'
Object required: 'split-this'
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我我错过了什么吗?
vbscript ×10
asp-classic ×3
arrays ×1
c# ×1
com ×1
datediff ×1
for-loop ×1
html ×1
ms-word ×1
non-greedy ×1
regex ×1
regex-greedy ×1
vba ×1
word-vba ×1