Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将vbscript转换为c#.net/VB.net?_C#_.net_Vb.net_Vbscript_Converter - Fatal编程技术网

将vbscript转换为c#.net/VB.net?

将vbscript转换为c#.net/VB.net?,c#,.net,vb.net,vbscript,converter,C#,.net,Vb.net,Vbscript,Converter,我遇到了一个问题。我有一个VBscript脚本,需要在C#.NET中转换(VB.NET也可以)。我是编程新手,不知道怎么做?一种传统的方法是用C#编写相同的代码。但是我的时间少了一点。有转换器吗,或者有人能给我一个开始吗?请建议我从哪里开始。它实际上是一个电子学习软件名为lectora,我需要将值从lectora传递到我的数据库。 任何帮助都将不胜感激。非常感谢。 这是我的VBscript代码 Sample ASP Script <%@ Language=VBScript %> &l

我遇到了一个问题。我有一个VBscript脚本,需要在C#.NET中转换(VB.NET也可以)。我是编程新手,不知道怎么做?一种传统的方法是用C#编写相同的代码。但是我的时间少了一点。有转换器吗,或者有人能给我一个开始吗?请建议我从哪里开始。它实际上是一个电子学习软件名为lectora,我需要将值从lectora传递到我的数据库。
任何帮助都将不胜感激。非常感谢。 这是我的VBscript代码

Sample ASP Script
<%@ Language=VBScript %>
<%
'Get the parameters posted from the test'
testname=Request.form("TestName")
score=Request.form("Score")
user=Request.form("name")
numQuestions=Request.form("NumQuestions")
passingGrade=Request.form("PassingGrade")
'Validate that this is actually from a Lectora test'
if testname="" Or score="" Or user="" Or numQuestions="" Or passingGrade="" then
 Response.Write "<html>"
 Response.Write "<head><title>Failure</title></head>"
Response.Write "<body>"
Response.Write "STATUS=500"
Response.Write "<br>"
Response.Write "Could not parse test results due to a parameter error."
Response.Write "</body></html>"
else
'Write the results to a file named the same as the test'
'This could be a database or any kind of object store, but'
'to keep it simple, we will just use a flat text file'
 fileName = "c:\" & testname & ".log"

'Open the results file for append'
 Const ForReading = 1, ForWriting = 2, ForAppending = 8

 Set objFSO = CreateObject("Scripting.FileSystemObject")

 if not objFSO.FileExists(fileName) then
  objFSO.CreateTextFile(fileName)
 end if

 Set objInFile = objFSO.OpenTextFile( fileName, ForAppending, True )

 'Write the results'
 objInFile.WriteLine( Date & ", " & Time & ", " & user & ", " & score )

  'Older courses produced by Lectora used a zero based index for the questions '
  '(i.e. Question0 is the first question)'
  'Newer courses are one based (i.e. Question1 is the first question)'
  'determine which one it is'
  Dim startIndex
  valTemp = Request.form("Question0")
  if( valTemp="" ) then
    startIndex=1
  else
    startIndex=0
  end if

  'Write all of the questions and answers'
   for i = startIndex to cint(startIndex + numQuestions-1)
     nameQ = "Question" + CStr(i)
     nameA = "Answer" + CStr(i)
     valQ = Request.form(nameQ)
     valA = Request.form(nameA)
     objInFile.WriteLine( nameQ & ": " & valQ )
     objInFile.WriteLine( nameA & ": " & valA )
    Next

    'Close results file'
     objInFile.Close
     Set objInFile = Nothing
      Set objFSO = Nothing
      end if 
      %>
示例ASP脚本

我会将代码直接复制到vb.net中,然后调试它。大多数代码是兼容的。有些事情,例如
Set objFSO=CreateObject(“Scripting.FileSystemObject”)
只需要稍作修改:
objFSO=new Scripting.FileSystemObject
(尽管有更现代的方法来完成文件io)。

它是用于Windows操作系统还是MacOS?