0
那麼我陷入了一個問題。我有一個VB腳本,我需要在C#.NET中轉換(VB.NET也可以)。我剛剛進入編程領域,對於如何去做並不太瞭解?一種傳統的方式是在C#中編寫相同的代碼。但我的時間不多。有沒有任何轉換器或者有人可以給我一個開始?請建議我從哪裏開始。它實際上是一個電子學習軟件名稱lectora,我需要將數值從lectora傳遞到我的數據庫。
任何幫助將被折扣。謝謝。 這是我的VB腳本代碼。將vbscript轉換爲c#.net/VB.NET?
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
%>