Det verkar som om det är en del som är ute och cyklar lite:
VBScript är ett subset av Visual Basic. För övrigt så kan man göra en hel del annat med VBScript än att använda det till ASP.
VBScript liksom ECMAScript (Jscript/Javascript) är ett scriptspråk som kan användas tillsammans med snartsagt vilken objektsmodell som helst.
Ett exempel på använding tillsammans med den DOM som IE använder:
<SCRIPT language="vbscript">
<!--
Dim current_status
current_status = 0
Sub document_onkeypress
If window.event.keyCode = 13 AND _
current_status = 1 Then
wholedoc.style.filter=""
messagebox1.style.visibility="hidden"
messagebox2.style.visibility="hidden"
current_status = 0
ElseIf window.event.keyCode = 72 Then
wholedoc.style.filter="Alpha(opacity=25)"
messagebox1.style.visibility="visible"
current_status = 1
ElseIf window.event.keyCode = 104 Then
wholedoc.style.filter="Alpha(opacity=25)"
messagebox2.style.visibility="visible"
current_status=1
End If
End Sub
'-->
</SCRIPT>
Ett annat exempel på använding tillsammans med den objektsmodell som IIS använder:
<%@ Language=VBScript%>
<%
Response.Redirect("thanx.asp")
%>
Ett tredje exempel på använding tillsammans med den objektsmodell som WHS använder:
Norpade coden från Microsoft
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to use the WSHNetwork object."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
' *
' * WSH Network Object.
' *
Dim WSHNetwork
Dim colDrives, SharePoint
Dim CRLF
CRLF = Chr(13) & Chr(10)
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Function Ask(strAction)
' This function asks the user whether to perform a specific "Action"
' and sets a return code or quits script execution depending on the
' button that the user presses. This function is called at various
' points in the script below.
Dim intButton
intButton = MsgBox(strAction, _
vbQuestion + vbYesNo, _
L_Welcome_MsgBox_Title_Text )
Ask = intButton = vbYes
End Function
' **************************************************
' *
' * Show WSHNetwork object properties
' *
' *
MsgBox "UserDomain" & Chr(9) & "= " & WSHNetwork.UserDomain & CRLF & _
"UserName" & Chr(9) & "= " & WSHNetwork.UserName & CRLF & _
"ComputerName" & Chr(9) & "= " & WSHNetwork.ComputerName, _
vbInformation + vbOKOnly, _
"WSHNetwork Properties"
' **************************************************
' *
' * WSHNetwork.AddNetworkDrive
' *
' *
Function TryMapDrive(intDrive, strShare)
Dim strDrive
strDrive = Chr(intDrive + 64) & ":"
On Error Resume Next
WSHNetwork.MapNetworkDrive strDrive, strShare
TryMapDrive = Err.Number = 0
End Function
If Ask("Do you want to connect a network drive?") Then
strShare = InputBox("Enter network share you want to connect to ")
For intDrive = 26 To 5 Step -1
If TryMapDrive(intDrive, strShare) Then Exit For
Next
If intDrive <= 5 Then
MsgBox "Unable to connect to network share. " & _
"There are currently no drive letters available for use. " & _
CRLF & _
"Please disconnect one of your existing network connections " & _
"and try this script again. ", _
vbExclamation + vbOkOnly, _
L_Welcome_MsgBox_Title_Text
Else
strDrive = Chr(intDrive + 64) & ":"
MsgBox "Connected " & strShare & " to drive " & strDrive, _
vbInformation + vbOkOnly, _
L_Welcome_MsgBox_Title_Text
If Ask("Do you want to disconnect the network drive you just created?") Then
WSHNetwork.RemoveNetworkDrive strDrive
MsgBox "Disconnected drive " & strDrive, _
vbInformation + vbOkOnly, _
L_Welcome_MsgBox_Title_Text
End If
End If
End If
' **************************************************
' *
' * WSHNetwork.EnumNetworkDrive
' *
' *
'Ask user whether to enumerate network drives
If Ask("Do you want to enumerate connected network drives?") Then
'Enumerate network drives into a collection object of type WshCollection
Set colDrives = WSHNetwork.EnumNetworkDrives
'If no network drives were enumerated, then inform user, else display
'enumerated drives
If colDrives.Count = 0 Then
MsgBox "There are no drives to enumerate.", _
vbInformation + vbOkOnly, _
L_Welcome_MsgBox_Title_Text
Else
strMsg = "Current network drive connections: " & CRLF
For i = 0 To colDrives.Count - 1 Step 2
strMsg = strMsg & CRLF & colDrives(i) & Chr(9) & colDrives(i + 1)
Next
MsgBox strMsg, _
vbInformation + vbOkOnly, _
L_Welcome_MsgBox_Title_Text
End If
End If
' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt
intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub
//R.G.B