Search is not available for this dataset
content
stringlengths 0
376M
|
---|
<filename>vba/examples/example2operators.bas
Public Sub Module()
X = 0
Y = 1
Z = 2
Test1 = X + Y * Z
Test2 = X - Y * Z
Test3 = Z + X * Y - Y * Z
Test4 = Z + X * Y Mod Z * 2 + 5 * Z
Test5 = Z + X ^ 3 * Y Mod Z * 2 + 5 * Z ^ X
End Sub
|
<filename>Task/Strip-a-set-of-characters-from-a-string/VBA/strip-a-set-of-characters-from-a-string.vba
Function StripChars(stString As String, stStripChars As String, Optional bSpace As Boolean)
Dim i As Integer, stReplace As String
If bSpace = True Then
stReplace = " "
Else
stReplace = ""
End If
For i = 1 To Len(stStripChars)
stString = Replace(stString, Mid(stStripChars, i, 1), stReplace)
Next i
StripChars = stString
End Function
|
on error resume next
'***********************************************************
'First pass - create an ISWbemServices object with "default"
'impersonation level
'***********************************************************
set service = GetObject("winmgmts:\\ludlow")
select case service.security_.impersonationlevel
case 1
ImpLevel = "Anonymous"
case 2
ImpLevel = "Identify"
case 3
ImpLevel = "Impersonate"
case 4
ImpLevel = "Delegate"
end select
WScript.Echo ""
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
& ImpLevel
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ""
for each Process in service.InstancesOf ("win32_process")
WScript.Echo Process.ProcessId, Process.name
next
if err <> 0 then
WScript.Echo "*** FAILED - as expected ***"
err.clear
else
WScript.Echo "*** SUCCEEDED - error ***"
end if
'****************************************************************
'Second pass - create an ISWbemServices object with Impersonation
'"enabled"
'****************************************************************
set service = GetObject("winmgmts:{impersonationLevel=impersonate}!//ludlow")
select case service.security_.impersonationlevel
case 1
ImpLevel = "Anonymous"
case 2
ImpLevel = "Identify"
case 3
ImpLevel = "Impersonate"
case 4
ImpLevel = "Delegate"
end select
WScript.Echo ""
WScript.Echo ""
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
& ImpLevel
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ""
for each Process in service.InstancesOf ("win32_process")
WScript.Echo Process.ProcessId, Process.name
next
WScript.Echo ""
if err <> 0 then
WScript.Echo "*** FAILED - error ***"
else
WScript.Echo "*** SUCCEEDED - as expected ***"
err.clear
end if
'****************************************************************
'Third pass - create an ISWbemServices object with Impersonation
'"anonymous"
'****************************************************************
set service = GetObject("winmgmts:{impersonationLevel=anonymous}!//ludlow")
select case service.security_.impersonationlevel
case 1
ImpLevel = "Anonymous"
case 2
ImpLevel = "Identify"
case 3
ImpLevel = "Impersonate"
case 4
ImpLevel = "Delegate"
end select
WScript.Echo ""
WScript.Echo ""
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
& ImpLevel
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ""
for each Process in service.InstancesOf ("win32_process")
WScript.Echo Process.ProcessId, Process.name
next
WScript.Echo ""
if err <> 0 then
WScript.Echo "*** FAILED - as expected ***"
err.clear
else
WScript.Echo "*** SUCCEEDED - error ***"
end if
'****************************************************************
'Third pass - create an ISWbemServices object with Impersonation
'"delegate"
'****************************************************************
set service = GetObject("winmgmts:{impersonationLevel=delegate}!//ludlow")
select case service.security_.impersonationlevel
case 1
ImpLevel = "Anonymous"
case 2
ImpLevel = "Identify"
case 3
ImpLevel = "Impersonate"
case 4
ImpLevel = "Delegate"
end select
WScript.Echo ""
WScript.Echo ""
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ">>Attempting enumeration of Win32_Process with impersonation set to " _
& ImpLevel
WScript.Echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
WScript.Echo ""
for each Process in service.InstancesOf ("win32_process")
WScript.Echo Process.ProcessId, Process.name
next
WScript.Echo ""
if err <> 0 then
WScript.Echo "*** FAILED - as expected ***"
err.clear
else
WScript.Echo "*** SUCCEEDED - error ***"
end if
|
<filename>base/cluster/admin/msclus/vbscript/test0.vbs
Option Explicit
Dim oCluster
Dim oProps
dim oValue
Set oCluster = CreateObject("MSCluster.Cluster")
oCluster.Open ("galenb-a-clus")
oValue = oCluster.CommonProperties.Item(8).Value
oCluster.CommonProperties.Item(9).Value = oCluster.CommonProperties.Item(9).Value
'WScript.Echo(oCluster.PrivateProperties.Item(1).Name)
'oCluster.PrivateProperties.Item(1).Name
'oCluster.PrivateProperties.Item(2).Name
'oCluster.PrivateProperties.Item(3).Name
WScript.Echo("Done")
|
<reponame>npocmaka/Windows-Server-2003
Attribute VB_Name = "Main"
Option Explicit
Private Const FIRST_C As Long = 0
Private Const SECOND_C As Long = 1
Private Const SEP_C As String = "<SEPARATOR>"
Private Const TAXONOMY_HHT_C As String = "Taxonomy.hht"
Private Const STOP_SIGNS_HHT_C As String = "StopSigns.hht"
Private Const STOP_WORDS_HHT_C As String = "StopWords.hht"
Private Const SYN_TABLE_HHT_C As String = "SynTable.hht"
Private Const SCOPE_DEFINITION_HHT_C As String = "ScopeDefinition.hht"
Private Const NO_LOC_HHT_C As String = "NoLoc.hht"
Private Const OPERATORS_HHT_C As String = "OperatorEntries.hht"
Private Const ELEM_METADATA_C As String = "METADATA"
Private Const ELEM_STOPWORD_ENTRIES_C As String = "STOPWORD_ENTRIES"
Private Const ELEM_STOPWORD_C As String = "STOPWORD"
Private Const ELEM_SCOPE_DEFINITION_C As String = "SCOPE_DEFINITION"
Private Const ELEM_SCOPE_C As String = "SCOPE"
Private Const ELEM_OPERATOR_ENTRIES_C As String = "OPERATOR_ENTRIES"
Private Const ELEM_OPERATOR_C As String = "OPERATOR"
Private Const ELEM_STOPSIGN_ENTRIES_C As String = "STOPSIGN_ENTRIES"
Private Const ELEM_STOPSIGN_C As String = "STOPSIGN"
Private Const ELEM_FTS_C As String = "FTS"
Private Const ELEM_INDEX_C As String = "INDEX"
Private Const ELEM_HELPIMAGE_C As String = "HELPIMAGE"
Private Const ELEM_HELPFILE_C As String = "HELPFILE"
Private Const ELEM_SYNTABLE_C As String = "SYNTABLE"
Private Const ELEM_SYNSET_C As String = "SYNSET"
Private Const ELEM_SYNONYM_C As String = "SYNONYM"
Private Const ELEM_KEYWORD_C As String = "KEYWORD"
Private Const ELEM_TAXONOMY_ENTRIES_C As String = "TAXONOMY_ENTRIES"
Private Const ELEM_TAXONOMY_ENTRY_C As String = "TAXONOMY_ENTRY"
Private Const ELEM_HHT_C As String = "HHT"
Private Const ATTR_STOPWORD_C As String = "STOPWORD"
Private Const ATTR_ACTION_C As String = "ACTION"
Private Const ATTR_ID_C As String = "ID"
Private Const ATTR_DISPLAYNAME_C As String = "DISPLAYNAME"
Private Const ATTR_OPERATION_C As String = "OPERATION"
Private Const ATTR_OPERATOR_C As String = "OPERATOR"
Private Const ATTR_CONTEXT_C As String = "CONTEXT"
Private Const ATTR_STOPSIGN_C As String = "STOPSIGN"
Private Const ATTR_CHM_C As String = "CHM"
Private Const ATTR_CHQ_C As String = "CHQ"
Private Const ATTR_HHK_C As String = "HHK"
Private Const ATTR_SCOPE_C As String = "SCOPE"
Private Const ATTR_CATEGORY_C As String = "CATEGORY"
Private Const ATTR_ENTRY_C As String = "ENTRY"
Private Const ATTR_URI_C As String = "URI"
Private Const ATTR_ICONURI_C As String = "ICONURI"
Private Const ATTR_TITLE_C As String = "TITLE"
Private Const ATTR_DESCRIPTION_C As String = "DESCRIPTION"
Private Const ATTR_TYPE_C As String = "TYPE"
Private Const ATTR_VISIBLE_C As String = "VISIBLE"
Private Const ATTR_SUBSITE_C As String = "SUBSITE"
Private Const ATTR_NAVIGATIONMODEL_C As String = "NAVIGATIONMODEL"
Private Const ATTR_PRIORITY_C As String = "PRIORITY"
Private Const ATTR_VALUE_C As String = "VALUE"
Private Const ATTR_FILE_C As String = "FILE"
Private Const VALUE_ADD_C As String = "ADD"
Private Const VALUE_DEL_C As String = "DEL"
Private Const VALUE_AND_C As String = "AND"
Private Const VALUE_OR_C As String = "OR"
Private Const VALUE_NOT_C As String = "NOT"
Private Const VALUE_ANYWHERE_C As String = "ANYWHERE"
Private Const VALUE_ENDOFWORD_C As String = "ENDOFWORD"
Private p_dictStopWords(1) As Scripting.Dictionary
Private p_dictHelpImage(1) As Scripting.Dictionary
Private p_dictScopes(1) As Scripting.Dictionary
Private p_dictFTS(1) As Scripting.Dictionary
Private p_dictOperators(1) As Scripting.Dictionary
Private p_dictStopSigns(1) As Scripting.Dictionary
Private p_dictIndex(1) As Scripting.Dictionary
Private p_dictSynTable(1) As Scripting.Dictionary
Private p_dictTaxonomy(1) As Scripting.Dictionary
Private p_strVersion As String
Private p_blnIgnoreKeywords As Boolean
Public Sub MainFunction( _
ByVal i_strCab1 As String, _
ByVal i_strCab2 As String, _
ByVal i_strCabOut As String, _
ByVal i_strVersion As String, _
ByVal i_blnIgnoreKeywords As Boolean _
)
On Error GoTo LError
Dim strFolder1 As String
Dim strFolder2 As String
Dim strFolderOut As String
Dim intErrorNumber As Long
Dim FSO As Scripting.FileSystemObject
Dim Folder As Scripting.Folder
Dim File As Scripting.File
p_strVersion = i_strVersion
p_blnIgnoreKeywords = i_blnIgnoreKeywords
strFolder1 = Cab2Folder(i_strCab1)
strFolder2 = Cab2Folder(i_strCab2)
Set FSO = New Scripting.FileSystemObject
strFolderOut = Environ$("TEMP") & "\__HSCCAB"
If (FSO.FolderExists(strFolderOut)) Then
FSO.DeleteFolder strFolderOut, Force:=True
End If
FSO.CreateFolder strFolderOut
p_GatherData FIRST_C, strFolder1
p_GatherData SECOND_C, strFolder2
p_CreateDeltaHHTs strFolderOut
Set Folder = FSO.GetFolder(strFolder1)
For Each File In Folder.Files
File.Copy strFolderOut & "\" & File.Name
Next
p_FixPackageDescription strFolderOut
Folder2Cab strFolderOut, i_strCabOut
LEnd:
DeleteCabFolder strFolder1
DeleteCabFolder strFolder2
DeleteCabFolder strFolderOut
Exit Sub
LError:
frmMain.Output Err.Description, LOGGING_TYPE_ERROR_E
intErrorNumber = Err.Number
DeleteCabFolder strFolder1
DeleteCabFolder strFolder2
DeleteCabFolder strFolderOut
Err.Raise intErrorNumber
End Sub
Private Sub p_GatherData( _
ByVal i_intIndex As Long, _
ByVal i_strFolder As String _
)
Dim DOMDocPkgDesc As MSXML2.DOMDocument
Dim intNumHHTs As Long
Dim intIndex As Long
Dim strFile As String
Set p_dictStopWords(i_intIndex) = New Scripting.Dictionary
p_dictStopWords(i_intIndex).CompareMode = TextCompare
Set p_dictHelpImage(i_intIndex) = New Scripting.Dictionary
p_dictHelpImage(i_intIndex).CompareMode = TextCompare
Set p_dictScopes(i_intIndex) = New Scripting.Dictionary
p_dictScopes(i_intIndex).CompareMode = TextCompare
Set p_dictFTS(i_intIndex) = New Scripting.Dictionary
p_dictFTS(i_intIndex).CompareMode = TextCompare
Set p_dictOperators(i_intIndex) = New Scripting.Dictionary
p_dictOperators(i_intIndex).CompareMode = TextCompare
Set p_dictStopSigns(i_intIndex) = New Scripting.Dictionary
p_dictStopSigns(i_intIndex).CompareMode = TextCompare
Set p_dictIndex(i_intIndex) = New Scripting.Dictionary
p_dictIndex(i_intIndex).CompareMode = TextCompare
Set p_dictSynTable(i_intIndex) = New Scripting.Dictionary
p_dictSynTable(i_intIndex).CompareMode = TextCompare
Set p_dictTaxonomy(i_intIndex) = New Scripting.Dictionary
p_dictTaxonomy(i_intIndex).CompareMode = TextCompare
Set DOMDocPkgDesc = GetPackageDescription(i_strFolder)
intNumHHTs = GetNumberOfHHTsListedInPackageDescription(DOMDocPkgDesc)
For intIndex = 1 To intNumHHTs
strFile = GetNthHHTListedInPackageDescription(DOMDocPkgDesc, intIndex)
p_ReadFile i_intIndex, i_strFolder, strFile
Next
End Sub
Private Sub p_ReadFile( _
ByVal i_intIndex As Long, _
ByVal i_strFolder As String, _
ByVal i_strFile As String _
)
Dim strLocation As String
Dim strPath As String
Dim DOMDoc As MSXML2.DOMDocument
If (i_intIndex = FIRST_C) Then
strLocation = " in first CAB"
Else
strLocation = " in second CAB"
End If
frmMain.Output "Processing " & i_strFile & strLocation & "...", LOGGING_TYPE_NORMAL_E
strPath = i_strFolder & "\" & i_strFile
Set DOMDoc = GetFileAsDomDocument(strPath)
p_ReadStopWords i_intIndex, DOMDoc
p_ReadHelpImage i_intIndex, DOMDoc
p_ReadScopes i_intIndex, DOMDoc
p_ReadFTS i_intIndex, DOMDoc
p_ReadOperators i_intIndex, DOMDoc
p_ReadStopSigns i_intIndex, DOMDoc
p_ReadIndex i_intIndex, DOMDoc
p_ReadSynTable i_intIndex, DOMDoc
p_ReadTaxonomy i_intIndex, DOMDoc
End Sub
Private Sub p_ReadStopWords( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strStopWord As String
Dim strAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/STOPWORD_ENTRIES/STOPWORD")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strStopWord = p_GetAttribute(DOMNode, "STOPWORD")
p_CheckAction "StopWord " & strStopWord, strAction
If (Not p_dictStopWords(i_intIndex).Exists(strStopWord)) Then
p_dictStopWords(i_intIndex).Add strStopWord, True
Else
frmMain.Output _
"StopWord " & strStopWord & " is defined twice.", LOGGING_TYPE_WARNING_E
End If
Next
End Sub
Private Sub p_ReadHelpImage( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strChm As String
Dim strAction As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/HELPIMAGE/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strChm = p_GetAttribute(DOMNode, "CHM")
p_CheckAction "HelpFile " & strChm, strAction
If (Not p_dictHelpImage(i_intIndex).Exists(strChm)) Then
p_dictHelpImage(i_intIndex).Add strChm, True
Else
frmMain.Output "HelpFile " & strChm & " is defined twice.", LOGGING_TYPE_WARNING_E
End If
Next
End Sub
Private Sub p_ReadScopes( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strId As String
Dim strAction As String
Dim strDisplayName As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/SCOPE_DEFINITION/SCOPE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strId = p_GetAttribute(DOMNode, "ID")
strDisplayName = p_GetAttribute(DOMNode, "DISPLAYNAME")
p_CheckAction "Scope " & strId, strAction
If (Not p_dictScopes(i_intIndex).Exists(strId)) Then
p_dictScopes(i_intIndex).Add strId, strDisplayName
Else
p_dictScopes(i_intIndex).Remove strId
p_dictScopes(i_intIndex).Add strId, strDisplayName
frmMain.Output _
"Scope " & strId & " is defined twice; previous definition will be ignored.", LOGGING_TYPE_WARNING_E
End If
Next
End Sub
Private Sub p_ReadFTS( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strAction As String
Dim strChm As String
Dim strChq As String
Dim strKey As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/FTS/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strChm = p_GetAttribute(DOMNode, "CHM")
strChq = p_GetAttribute(DOMNode, "CHQ", False)
strKey = strChm & SEP_C & strChq
p_CheckAction "FTS file " & strKey, strAction
If (Not p_dictFTS(i_intIndex).Exists(strKey)) Then
p_dictFTS(i_intIndex).Add strKey, True
Else
frmMain.Output "FTS file " & strKey & " is defined twice.", LOGGING_TYPE_WARNING_E
End If
Next
End Sub
Private Sub p_ReadOperators( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strOperator As String
Dim strAction As String
Dim strOperation As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/OPERATOR_ENTRIES/OPERATOR")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strOperation = p_GetAttribute(DOMNode, "OPERATION")
strOperator = p_GetAttribute(DOMNode, "OPERATOR")
p_CheckAction "Operator " & strOperator, strAction
p_CheckOperation "Operator " & strOperator, strOperation
If (Not p_dictOperators(i_intIndex).Exists(strOperator)) Then
p_dictOperators(i_intIndex).Add strOperator, strOperation
Else
Err.Raise E_FAIL, , "Operator " & strOperator & " is defined twice."
End If
Next
End Sub
Private Sub p_ReadStopSigns( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strStopSign As String
Dim strAction As String
Dim strContext As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/STOPSIGN_ENTRIES/STOPSIGN")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strContext = p_GetAttribute(DOMNode, "CONTEXT")
strStopSign = p_GetAttribute(DOMNode, "STOPSIGN")
p_CheckAction "StopSign " & strStopSign, strAction
p_CheckContext "StopSign " & strStopSign, strContext
If (Not p_dictStopSigns(i_intIndex).Exists(strStopSign)) Then
p_dictStopSigns(i_intIndex).Add strStopSign, strContext
Else
Err.Raise E_FAIL, , "StopSign " & strStopSign & " is defined twice."
End If
Next
End Sub
Private Sub p_ReadIndex( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim strAction As String
Dim strChm As String
Dim strHhk As String
Dim strScope As String
Dim strKey As String
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/INDEX/HELPFILE")
For Each DOMNode In DOMNodeList
DoEvents
strAction = p_GetAttribute(DOMNode, "ACTION")
strChm = p_GetAttribute(DOMNode, "CHM")
strHhk = p_GetAttribute(DOMNode, "HHK")
strScope = p_GetAttribute(DOMNode, "SCOPE", False)
strKey = strChm & SEP_C & strHhk
p_CheckAction "Index " & strKey, strAction
If (Not p_dictIndex(i_intIndex).Exists(strKey)) Then
p_dictIndex(i_intIndex).Add strKey, strScope
Else
Err.Raise E_FAIL, , "Index " & strChm & "/" & strHhk & " is defined twice."
End If
Next
End Sub
Private Sub p_ReadSynTable( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeSynSetList As MSXML2.IXMLDOMNodeList
Dim DOMNodeSynonymList As MSXML2.IXMLDOMNodeList
Dim DOMNodeSynSet As MSXML2.IXMLDOMNode
Dim DOMNodeSynonym As MSXML2.IXMLDOMNode
Dim dict As Scripting.Dictionary
Dim strId As String
Dim strSynonym As String
Dim strAction As String
Set DOMNodeSynSetList = i_DOMDoc.selectNodes("METADATA/SYNTABLE/SYNSET")
For Each DOMNodeSynSet In DOMNodeSynSetList
DoEvents
strId = p_GetAttribute(DOMNodeSynSet, "ID")
If (p_dictSynTable(i_intIndex).Exists(strId)) Then
Set dict = p_dictSynTable(i_intIndex)(strId)
Else
Set dict = New Scripting.Dictionary
dict.CompareMode = TextCompare
p_dictSynTable(i_intIndex).Add strId, dict
End If
Set DOMNodeSynonymList = DOMNodeSynSet.selectNodes("SYNONYM")
For Each DOMNodeSynonym In DOMNodeSynonymList
DoEvents
strSynonym = DOMNodeSynonym.Text
strAction = p_GetAttribute(DOMNodeSynonym, "ACTION")
p_CheckAction "SynSet " & strId & ": " & "Synonym " & strSynonym, strAction
If (Not dict.Exists(strSynonym)) Then
dict.Add strSynonym, True
Else
frmMain.Output "Synonym " & strSynonym & " is defined twice in SynSet " & strId & ".", _
LOGGING_TYPE_WARNING_E
End If
Next
Next
End Sub
Private Sub p_ReadTaxonomy( _
ByVal i_intIndex As Long, _
ByVal i_DOMDoc As MSXML2.DOMDocument _
)
Dim DOMNodeList As MSXML2.IXMLDOMNodeList
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMNodeListKW As MSXML2.IXMLDOMNodeList
Dim DOMNodeKW As MSXML2.IXMLDOMNode
Dim strCategory As String
Dim strEntry As String
Dim strURI As String
Dim strKey As String
Dim strKeyword As String
Dim strPriority As String
Dim Taxonomy As Taxonomy
Dim intIndex As Long
Dim blnNode As Boolean
Set DOMNodeList = i_DOMDoc.selectNodes("METADATA/TAXONOMY_ENTRIES/TAXONOMY_ENTRY")
If (DOMNodeList.length <> 0) Then
frmMain.ProgresBar_SetMax DOMNodeList.length
End If
For Each DOMNode In DOMNodeList
intIndex = intIndex + 1
frmMain.ProgresBar_SetValue intIndex
DoEvents
strCategory = p_GetAttribute(DOMNode, ATTR_CATEGORY_C)
strEntry = p_GetAttribute(DOMNode, ATTR_ENTRY_C, False)
strURI = p_GetAttribute(DOMNode, ATTR_URI_C, False)
Set Taxonomy = New Taxonomy
With Taxonomy
If (strEntry <> "") Then
blnNode = True
strKey = strCategory & SEP_C & strEntry
Else
blnNode = False
strKey = strCategory & SEP_C & strURI
End If
.strCategory = strCategory
.strEntry = strEntry
.strURI = strURI
.strIconURI = p_GetAttribute(DOMNode, ATTR_ICONURI_C, False)
.strTitle = p_GetAttribute(DOMNode, ATTR_TITLE_C, False)
.strDescription = p_GetAttribute(DOMNode, ATTR_DESCRIPTION_C, False)
.strType = p_GetAttribute(DOMNode, ATTR_TYPE_C, False)
.strVisible = p_GetAttribute(DOMNode, ATTR_VISIBLE_C, False)
.strSubSite = p_GetAttribute(DOMNode, ATTR_SUBSITE_C, False)
.strNavigationModel = p_GetAttribute(DOMNode, ATTR_NAVIGATIONMODEL_C, False)
If (Not blnNode) Then
Set .dictKeywords = New Scripting.Dictionary
Set DOMNodeListKW = DOMNode.selectNodes(ELEM_KEYWORD_C)
For Each DOMNodeKW In DOMNodeListKW
strKeyword = DOMNodeKW.Text
strPriority = p_GetAttribute(DOMNodeKW, ATTR_PRIORITY_C, False)
.dictKeywords.Add strKeyword, strPriority
Next
End If
End With
If (Not p_dictTaxonomy(i_intIndex).Exists(strKey)) Then
p_dictTaxonomy(i_intIndex).Add strKey, Taxonomy
Else
frmMain.Output "Taxonomy entry """ & strKey & """ is defined twice", LOGGING_TYPE_WARNING_E
End If
Next
frmMain.ProgresBar_SetValue 0
End Sub
Private Sub p_CheckAction( _
ByVal i_strPrefix As String, _
ByVal i_strAction As String _
)
If (UCase$(i_strAction) <> VALUE_ADD_C) Then
Err.Raise E_FAIL, , i_strPrefix & ": ACTION " & i_strAction & " cannot be handled."
End If
End Sub
Private Sub p_CheckOperation( _
ByVal i_strPrefix As String, _
ByVal i_strOperation As String _
)
Dim strOperation As String
strOperation = UCase$(i_strOperation)
If ((strOperation <> "AND") And (strOperation <> "OR") And (strOperation <> "NOT")) Then
Err.Raise E_FAIL, , i_strPrefix & ": Bad OPERATION: " & i_strOperation
End If
End Sub
Private Sub p_CheckContext( _
ByVal i_strPrefix As String, _
ByVal i_strContext As String _
)
Dim strContext As String
strContext = UCase$(i_strContext)
If ((strContext <> "ANYWHERE") And (strContext <> "ENDOFWORD")) Then
Err.Raise E_FAIL, , i_strPrefix & ": Bad CONTEXT: " & i_strContext
End If
End Sub
Private Function p_GetAttribute( _
ByVal i_DOMNode As MSXML2.IXMLDOMNode, _
ByVal i_strAttributeName As String, _
Optional ByVal i_blnRequired As Boolean = True _
) As String
Dim DOMAttribute As MSXML2.IXMLDOMAttribute
Set DOMAttribute = i_DOMNode.Attributes.getNamedItem(i_strAttributeName)
If (DOMAttribute Is Nothing) Then
If (Not i_blnRequired) Then
Exit Function
Else
Err.Raise E_FAIL, , "Attribute " & i_strAttributeName & " is missing in: " & i_DOMNode.xml
End If
End If
' p_GetAttribute = Replace$(DOMAttribute.Text, "\", "\\")
p_GetAttribute = DOMAttribute.Text
End Function
Private Sub p_CreateDeltaHHTs( _
ByVal i_strFolder As String _
)
p_CreateStopWordsDelta i_strFolder & "\" & p_strVersion & "_" & STOP_WORDS_HHT_C
p_CreateHelpImageFTSIndexDelta i_strFolder & "\" & p_strVersion & "_" & NO_LOC_HHT_C
p_CreateScopesDelta i_strFolder & "\" & p_strVersion & "_" & SCOPE_DEFINITION_HHT_C
p_CreateOperatorsDelta i_strFolder & "\" & p_strVersion & "_" & OPERATORS_HHT_C
p_CreateStopSignsDelta i_strFolder & "\" & p_strVersion & "_" & STOP_SIGNS_HHT_C
p_CreateSynTableDelta i_strFolder & "\" & p_strVersion & "_" & SYN_TABLE_HHT_C
p_CreateTaxonomyDelta i_strFolder & "\" & p_strVersion & "_" & TAXONOMY_HHT_C
End Sub
Private Function p_GetNewDomDoc( _
) As MSXML2.DOMDocument
Dim DOMDoc As MSXML2.DOMDocument
Dim PI As MSXML2.IXMLDOMProcessingInstruction
Dim DOMComment As MSXML2.IXMLDOMComment
Dim DOMElement As MSXML2.IXMLDOMElement
Set DOMDoc = New MSXML2.DOMDocument
DOMDoc.preserveWhiteSpace = True
Set PI = DOMDoc.createProcessingInstruction("xml", "version='1.0' encoding='UTF-16'")
DOMDoc.appendChild PI
Set DOMComment = DOMDoc.createComment("Insert your comments here")
DOMDoc.appendChild DOMComment
Set DOMElement = DOMDoc.createElement(ELEM_METADATA_C)
DOMDoc.appendChild DOMElement
Set p_GetNewDomDoc = DOMDoc
End Function
Private Sub p_CreateStopWordsDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strStopWord As Variant
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_STOPWORD_ENTRIES_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
For Each strStopWord In p_dictStopWords(SECOND_C).Keys
p_dictStopWords(SECOND_C).Remove strStopWord
If (p_dictStopWords(FIRST_C).Exists(strStopWord)) Then
' StopWord exists in both CABs. Ignore.
p_dictStopWords(FIRST_C).Remove strStopWord
Else
' StopWord exists only in the new CAB. Add it in the Delta.
Set DOMElement = DOMDoc.createElement(ELEM_STOPWORD_C)
With DOMElement
.setAttribute ATTR_STOPWORD_C, strStopWord
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
DOMNode.appendChild DOMElement
End If
Next
For Each strStopWord In p_dictStopWords(FIRST_C).Keys
' StopWord exists only in the old CAB. Remove it in the Delta.
Set DOMElement = DOMDoc.createElement(ELEM_STOPWORD_C)
With DOMElement
.setAttribute ATTR_STOPWORD_C, strStopWord
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
Next
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateScopesDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strId As Variant
Dim strName1 As String
Dim strName2 As String
Dim blnAdd As Boolean
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_SCOPE_DEFINITION_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
For Each strId In p_dictScopes(SECOND_C).Keys
strName2 = p_dictScopes(SECOND_C)(strId)
p_dictScopes(SECOND_C).Remove strId
If (p_dictScopes(FIRST_C).Exists(strId)) Then
strName1 = p_dictScopes(FIRST_C)(strId)
p_dictScopes(FIRST_C).Remove strId
If (strName1 = strName2) Then
blnAdd = False
Else
' Scope name changed. Add it in the Delta.
blnAdd = True
End If
Else
' Scope exists only in the new CAB. Add it in the Delta.
blnAdd = True
End If
If (blnAdd) Then
Set DOMElement = DOMDoc.createElement(ELEM_SCOPE_C)
With DOMElement
.setAttribute ATTR_ID_C, strId
.setAttribute ATTR_DISPLAYNAME_C, strName2
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
DOMNode.appendChild DOMElement
End If
Next
For Each strId In p_dictScopes(FIRST_C).Keys
' Scope exists only in the old CAB. Remove it in the Delta.
Set DOMElement = DOMDoc.createElement(ELEM_SCOPE_C)
With DOMElement
.setAttribute ATTR_ID_C, strId
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
Next
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateOperatorsDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strOperator As Variant
Dim strOperation1 As String
Dim strOperation2 As String
Dim blnAdd As Boolean
Dim blnDel As Boolean
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_OPERATOR_ENTRIES_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
For Each strOperator In p_dictOperators(SECOND_C).Keys
strOperation2 = p_dictOperators(SECOND_C)(strOperator)
p_dictOperators(SECOND_C).Remove strOperator
blnDel = False
If (p_dictOperators(FIRST_C).Exists(strOperator)) Then
strOperation1 = p_dictOperators(FIRST_C)(strOperator)
p_dictOperators(FIRST_C).Remove strOperator
If (strOperation1 = strOperation2) Then
blnAdd = False
Else
' Operation changed. Add it in the Delta.
blnAdd = True
blnDel = True
End If
Else
' Operator exists only in the new CAB. Add it in the Delta.
blnAdd = True
End If
If (blnDel) Then
Set DOMElement = DOMDoc.createElement(ELEM_OPERATOR_C)
With DOMElement
.setAttribute ATTR_OPERATOR_C, strOperator
.setAttribute ATTR_OPERATION_C, strOperation1
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
End If
If (blnAdd) Then
Set DOMElement = DOMDoc.createElement(ELEM_OPERATOR_C)
With DOMElement
.setAttribute ATTR_OPERATOR_C, strOperator
.setAttribute ATTR_OPERATION_C, strOperation2
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
DOMNode.appendChild DOMElement
End If
Next
For Each strOperator In p_dictOperators(FIRST_C).Keys
strOperation1 = p_dictOperators(FIRST_C)(strOperator)
' Operator exists only in the old CAB. Remove it in the Delta.
Set DOMElement = DOMDoc.createElement(ELEM_OPERATOR_C)
With DOMElement
.setAttribute ATTR_OPERATOR_C, strOperator
.setAttribute ATTR_OPERATION_C, strOperation1
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
Next
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateStopSignsDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strStopSign As Variant
Dim strContext1 As String
Dim strContext2 As String
Dim blnAdd As Boolean
Dim blnDel As Boolean
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_STOPSIGN_ENTRIES_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
For Each strStopSign In p_dictStopSigns(SECOND_C).Keys
strContext2 = p_dictStopSigns(SECOND_C)(strStopSign)
p_dictStopSigns(SECOND_C).Remove strStopSign
blnDel = False
If (p_dictStopSigns(FIRST_C).Exists(strStopSign)) Then
strContext1 = p_dictStopSigns(FIRST_C)(strStopSign)
p_dictStopSigns(FIRST_C).Remove strStopSign
If (strContext1 = strContext2) Then
blnAdd = False
Else
' Context changed. Add it in the Delta.
blnAdd = True
blnDel = True
End If
Else
' StopSign exists only in the new CAB. Add it in the Delta.
blnAdd = True
End If
If (blnDel) Then
Set DOMElement = DOMDoc.createElement(ELEM_STOPSIGN_C)
With DOMElement
.setAttribute ATTR_STOPSIGN_C, strStopSign
.setAttribute ATTR_CONTEXT_C, strContext1
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
End If
If (blnAdd) Then
Set DOMElement = DOMDoc.createElement(ELEM_STOPSIGN_C)
With DOMElement
.setAttribute ATTR_STOPSIGN_C, strStopSign
.setAttribute ATTR_CONTEXT_C, strContext2
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
DOMNode.appendChild DOMElement
End If
Next
For Each strStopSign In p_dictStopSigns(FIRST_C).Keys
strContext1 = p_dictStopSigns(FIRST_C)(strStopSign)
' StopSign exists only in the old CAB. Remove it in the Delta.
Set DOMElement = DOMDoc.createElement(ELEM_STOPSIGN_C)
With DOMElement
.setAttribute ATTR_STOPSIGN_C, strStopSign
.setAttribute ATTR_CONTEXT_C, strContext1
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
DOMNode.appendChild DOMElement
Next
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateHelpImageFTSIndexDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_HELPIMAGE_C)
DOMNode.appendChild DOMElement
p_CreateHelpImageDelta DOMDoc, DOMElement
Set DOMElement = DOMDoc.createElement(ELEM_FTS_C)
DOMNode.appendChild DOMElement
p_CreateFTSDelta DOMDoc, DOMElement
Set DOMElement = DOMDoc.createElement(ELEM_INDEX_C)
DOMNode.appendChild DOMElement
p_CreateIndexDelta DOMDoc, DOMElement
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateHelpImageDelta( _
ByVal u_DOMDoc As MSXML2.DOMDocument, _
ByVal u_DOMNode As MSXML2.IXMLDOMNode _
)
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strChm As Variant
For Each strChm In p_dictHelpImage(SECOND_C).Keys
p_dictHelpImage(SECOND_C).Remove strChm
If (p_dictHelpImage(FIRST_C).Exists(strChm)) Then
' HelpImage exists in both CABs. Ignore.
p_dictHelpImage(FIRST_C).Remove strChm
Else
' HelpImage exists only in the new CAB. Add it in the Delta.
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
With DOMElement
.setAttribute ATTR_CHM_C, strChm
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
u_DOMNode.appendChild DOMElement
End If
Next
For Each strChm In p_dictHelpImage(FIRST_C).Keys
' HelpImage exists only in the old CAB. Remove it in the Delta.
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
With DOMElement
.setAttribute ATTR_CHM_C, strChm
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
u_DOMNode.appendChild DOMElement
Next
End Sub
Private Sub p_CreateFTSDelta( _
ByVal u_DOMDoc As MSXML2.DOMDocument, _
ByVal u_DOMNode As MSXML2.IXMLDOMNode _
)
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strKey As Variant
Dim arr() As String
For Each strKey In p_dictFTS(SECOND_C).Keys
p_dictFTS(SECOND_C).Remove strKey
If (p_dictFTS(FIRST_C).Exists(strKey)) Then
' FTS exists in both CABs. Ignore.
p_dictFTS(FIRST_C).Remove strKey
Else
' FTS exists only in the new CAB. Add it in the Delta.
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
arr = Split(strKey, SEP_C)
With DOMElement
.setAttribute ATTR_CHM_C, arr(0)
If (arr(1) <> "") Then
.setAttribute ATTR_CHQ_C, arr(1)
End If
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
u_DOMNode.appendChild DOMElement
End If
Next
For Each strKey In p_dictFTS(FIRST_C).Keys
' FTS exists only in the old CAB. Remove it in the Delta.
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
arr = Split(strKey, SEP_C)
With DOMElement
.setAttribute ATTR_CHM_C, arr(0)
If (arr(1) <> "") Then
.setAttribute ATTR_CHQ_C, arr(1)
End If
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
u_DOMNode.appendChild DOMElement
Next
End Sub
Private Sub p_CreateIndexDelta( _
ByVal u_DOMDoc As MSXML2.DOMDocument, _
ByVal u_DOMNode As MSXML2.IXMLDOMNode _
)
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strKey As Variant
Dim arr() As String
Dim strScope1 As String
Dim strScope2 As String
Dim blnAdd As Boolean
Dim blnDel As Boolean
For Each strKey In p_dictIndex(SECOND_C).Keys
strScope2 = p_dictIndex(SECOND_C)(strKey)
p_dictIndex(SECOND_C).Remove strKey
blnDel = False
If (p_dictIndex(FIRST_C).Exists(strKey)) Then
strScope1 = p_dictIndex(FIRST_C)(strKey)
p_dictIndex(FIRST_C).Remove strKey
If (strScope1 = strScope2) Then
blnAdd = False
Else
' Scope changed. Add it in the Delta.
blnAdd = True
blnDel = True
End If
Else
' Index exists only in the new CAB. Add it in the Delta.
blnAdd = True
End If
arr = Split(strKey, SEP_C)
If (blnDel) Then
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
With DOMElement
.setAttribute ATTR_CHM_C, arr(0)
.setAttribute ATTR_HHK_C, arr(1)
If (strScope1 <> "") Then
.setAttribute ATTR_SCOPE_C, strScope1
End If
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
u_DOMNode.appendChild DOMElement
End If
If (blnAdd) Then
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
With DOMElement
.setAttribute ATTR_CHM_C, arr(0)
.setAttribute ATTR_HHK_C, arr(1)
If (strScope2 <> "") Then
.setAttribute ATTR_SCOPE_C, strScope2
End If
.setAttribute ATTR_ACTION_C, VALUE_ADD_C
End With
u_DOMNode.appendChild DOMElement
End If
Next
For Each strKey In p_dictIndex(FIRST_C).Keys
strScope1 = p_dictIndex(FIRST_C)(strKey)
arr = Split(strKey, SEP_C)
' Index exists only in the old CAB. Remove it in the Delta.
Set DOMElement = u_DOMDoc.createElement(ELEM_HELPFILE_C)
With DOMElement
.setAttribute ATTR_CHM_C, arr(0)
.setAttribute ATTR_HHK_C, arr(1)
If (strScope1 <> "") Then
.setAttribute ATTR_SCOPE_C, strScope1
End If
.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End With
u_DOMNode.appendChild DOMElement
Next
End Sub
Private Sub p_CreateSynTableDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMNodeSynSet As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strId As Variant
Dim dict1 As Scripting.Dictionary
Dim dict2 As Scripting.Dictionary
Dim strSynonym As Variant
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_SYNTABLE_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
Dim strKey As Variant
Dim arr() As String
Dim strScope1 As String
Dim strScope2 As String
Dim blnAdd As Boolean
Dim blnDel As Boolean
For Each strId In p_dictSynTable(SECOND_C).Keys
Set dict2 = p_dictSynTable(SECOND_C)(strId)
If (p_dictSynTable(FIRST_C).Exists(strId)) Then
Set dict1 = p_dictSynTable(FIRST_C)(strId)
p_dictSynTable(FIRST_C).Remove strId
p_dictSynTable(SECOND_C).Remove strId
For Each strSynonym In dict2.Keys
If (dict1.Exists(strSynonym)) Then
dict1.Remove strSynonym
dict2.Remove strSynonym
End If
Next
If ((dict1.Count <> 0) Or (dict2.Count <> 0)) Then
Set DOMElement = DOMDoc.createElement(ELEM_SYNSET_C)
DOMElement.setAttribute ATTR_ID_C, strId
DOMNode.appendChild DOMElement
Set DOMNodeSynSet = DOMElement
For Each strSynonym In dict1.Keys
Set DOMElement = DOMDoc.createElement(ELEM_SYNONYM_C)
DOMElement.setAttribute ATTR_ACTION_C, VALUE_DEL_C
DOMElement.Text = strSynonym
DOMNodeSynSet.appendChild DOMElement
Next
For Each strSynonym In dict2.Keys
Set DOMElement = DOMDoc.createElement(ELEM_SYNONYM_C)
DOMElement.setAttribute ATTR_ACTION_C, VALUE_ADD_C
DOMElement.Text = strSynonym
DOMNodeSynSet.appendChild DOMElement
Next
End If
End If
Next
For Each strId In p_dictSynTable(FIRST_C).Keys
Set dict1 = p_dictSynTable(FIRST_C)(strId)
p_dictSynTable(FIRST_C).Remove strId
Set DOMElement = DOMDoc.createElement(ELEM_SYNSET_C)
DOMElement.setAttribute ATTR_ID_C, strId
DOMNode.appendChild DOMElement
Set DOMNodeSynSet = DOMElement
For Each strSynonym In dict1.Keys
Set DOMElement = DOMDoc.createElement(ELEM_SYNONYM_C)
DOMElement.setAttribute ATTR_ACTION_C, VALUE_DEL_C
DOMElement.Text = strSynonym
DOMNodeSynSet.appendChild DOMElement
Next
Next
For Each strId In p_dictSynTable(SECOND_C).Keys
Set dict2 = p_dictSynTable(SECOND_C)(strId)
p_dictSynTable(SECOND_C).Remove strId
Set DOMElement = DOMDoc.createElement(ELEM_SYNSET_C)
DOMElement.setAttribute ATTR_ID_C, strId
DOMNode.appendChild DOMElement
Set DOMNodeSynSet = DOMElement
For Each strSynonym In dict2.Keys
Set DOMElement = DOMDoc.createElement(ELEM_SYNONYM_C)
DOMElement.setAttribute ATTR_ACTION_C, VALUE_ADD_C
DOMElement.Text = strSynonym
DOMNodeSynSet.appendChild DOMElement
Next
Next
DOMDoc.Save i_strFile
End Sub
Private Sub p_CreateTaxonomyDelta( _
ByVal i_strFile As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMNode As MSXML2.IXMLDOMNode
Dim DOMElement As MSXML2.IXMLDOMElement
Dim strKey As Variant
Dim Taxonomy1 As Taxonomy
Dim Taxonomy2 As Taxonomy
Dim blnKeywordsRemoved As Boolean
Dim intIndex As Long
Set DOMDoc = p_GetNewDomDoc
Set DOMNode = DOMDoc.selectSingleNode(ELEM_METADATA_C)
Set DOMElement = DOMDoc.createElement(ELEM_TAXONOMY_ENTRIES_C)
DOMNode.appendChild DOMElement
Set DOMNode = DOMElement
If (p_dictTaxonomy(SECOND_C).Count <> 0) Then
frmMain.ProgresBar_SetMax p_dictTaxonomy(SECOND_C).Count
End If
For Each strKey In p_dictTaxonomy(SECOND_C).Keys
intIndex = intIndex + 1
frmMain.ProgresBar_SetValue intIndex
DoEvents
Set Taxonomy2 = p_dictTaxonomy(SECOND_C)(strKey)
p_dictTaxonomy(SECOND_C).Remove strKey
Set Taxonomy1 = Nothing
If (p_dictTaxonomy(FIRST_C).Exists(strKey)) Then
Set Taxonomy1 = p_dictTaxonomy(FIRST_C)(strKey)
p_dictTaxonomy(FIRST_C).Remove strKey
End If
blnKeywordsRemoved = False
If ((Taxonomy1 Is Nothing) Or _
(Not Taxonomy2.SameAs(Taxonomy1, p_blnIgnoreKeywords, blnKeywordsRemoved))) Then
If (blnKeywordsRemoved) Then
frmMain.Output "Keywords have been removed from Taxonomy entry """ & strKey & """.", _
LOGGING_TYPE_WARNING_E
frmMain.Output "Keyword removal is not supported.", LOGGING_TYPE_WARNING_E
Else
p_InsertTaxonomyEntry DOMDoc, DOMNode, Taxonomy2, True
End If
End If
Next
frmMain.ProgresBar_SetValue 0
If (p_dictTaxonomy(FIRST_C).Count <> 0) Then
frmMain.ProgresBar_SetMax p_dictTaxonomy(FIRST_C).Count
End If
intIndex = 0
For Each strKey In p_dictTaxonomy(FIRST_C).Keys
intIndex = intIndex + 1
frmMain.ProgresBar_SetValue intIndex
DoEvents
Set Taxonomy1 = p_dictTaxonomy(FIRST_C)(strKey)
If (Taxonomy1.strEntry <> "") Then
Err.Raise E_FAIL, , "Node """ & strKey & """ has been deleted. This is not supported."
End If
p_InsertTaxonomyEntry DOMDoc, DOMNode, Taxonomy1, False
Next
frmMain.ProgresBar_SetValue 0
DOMDoc.Save i_strFile
End Sub
Private Sub p_InsertTaxonomyEntry( _
ByRef u_DOMDoc As MSXML2.DOMDocument, _
ByRef u_DOMNode As MSXML2.IXMLDOMNode, _
ByRef i_Taxonomy As Taxonomy, _
ByVal i_blnAdd As Boolean _
)
Dim DOMElement As MSXML2.IXMLDOMElement
Dim DOMElementKw As MSXML2.IXMLDOMElement
Dim strKeyword As Variant
Dim strPriority As String
Set DOMElement = u_DOMDoc.createElement(ELEM_TAXONOMY_ENTRY_C)
With i_Taxonomy
DOMElement.setAttribute ATTR_CATEGORY_C, .strCategory
If (.strEntry <> "") Then
DOMElement.setAttribute ATTR_ENTRY_C, .strEntry
End If
DOMElement.setAttribute ATTR_URI_C, .strURI
DOMElement.setAttribute ATTR_TITLE_C, .strTitle
If (i_blnAdd) Then
DOMElement.setAttribute ATTR_ICONURI_C, .strIconURI
DOMElement.setAttribute ATTR_DESCRIPTION_C, .strDescription
If (.strType <> "") Then
DOMElement.setAttribute ATTR_TYPE_C, .strType
End If
If (.strVisible <> "") Then
DOMElement.setAttribute ATTR_VISIBLE_C, .strVisible
End If
If (.strSubSite <> "") Then
DOMElement.setAttribute ATTR_SUBSITE_C, .strSubSite
End If
If (.strNavigationModel <> "") Then
DOMElement.setAttribute ATTR_NAVIGATIONMODEL_C, .strNavigationModel
End If
End If
If (i_blnAdd) Then
DOMElement.setAttribute ATTR_ACTION_C, VALUE_ADD_C
Else
DOMElement.setAttribute ATTR_ACTION_C, VALUE_DEL_C
End If
If (i_blnAdd And (Not .dictKeywords Is Nothing)) Then
For Each strKeyword In .dictKeywords.Keys
Set DOMElementKw = u_DOMDoc.createElement(ELEM_KEYWORD_C)
DOMElementKw.Text = strKeyword
strPriority = .dictKeywords(strKeyword)
If (strPriority <> "") Then
DOMElementKw.setAttribute ATTR_PRIORITY_C, strPriority
End If
DOMElement.appendChild DOMElementKw
Next
End If
End With
u_DOMNode.appendChild DOMElement
End Sub
Private Sub p_FixPackageDescription( _
ByVal i_strFolder As String _
)
Dim DOMDoc As MSXML2.DOMDocument
Dim DOMElement As MSXML2.IXMLDOMElement
Dim DOMElementHHT As MSXML2.IXMLDOMElement
Set DOMDoc = GetPackageDescription(i_strFolder)
Set DOMElement = DOMDoc.selectSingleNode("HELPCENTERPACKAGE/VERSION")
DOMElement.setAttribute ATTR_VALUE_C, p_strVersion
Set DOMElement = DOMDoc.selectSingleNode("HELPCENTERPACKAGE/METADATA")
' The order in which the HHTs are listed is important.
' For example, The synonym table must appear before the taxonomy.
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & OPERATORS_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & STOP_SIGNS_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & STOP_WORDS_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & SYN_TABLE_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & TAXONOMY_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & SCOPE_DEFINITION_HHT_C
DOMElement.appendChild DOMElementHHT
Set DOMElementHHT = DOMDoc.createElement(ELEM_HHT_C)
DOMElementHHT.setAttribute ATTR_FILE_C, p_strVersion & "_" & NO_LOC_HHT_C
DOMElement.appendChild DOMElementHHT
DOMDoc.Save i_strFolder & "\" & PKG_DESC_FILE_C
End Sub
|
Public Sub nine_billion_names()
Dim p(25, 25) As Long
p(1, 1) = 1
For i = 2 To 25
For j = 1 To i
p(i, j) = p(i - 1, j - 1) + p(i - j, j)
Next j
Next i
For i = 1 To 25
Debug.Print String$(50 - 2 * i, " ");
For j = 1 To i
Debug.Print String$(4 - Len(CStr(p(i, j))), " ") & p(i, j);
Next j
Debug.Print
Next i
End Sub
|
Public Sub string_matching()
word = "the" '-- (also try this with "th"/"he")
sentence = "the last thing the man said was the"
'-- sentence = "thelastthingthemansaidwasthe" '-- (practically the same results)
'-- A common, but potentially inefficient idiom for checking for a substring at the start is:
If InStr(1, sentence, word) = 1 Then
Debug.Print "yes(1)"
End If
'-- A more efficient method is to test the appropriate slice
If Len(sentence) >= Len(word) _
And Mid(sentence, 1, Len(word)) = word Then
Debug.Print "yes(2)"
End If
'-- Which is almost identical to checking for a word at the end
If Len(sentence) >= Len(word) _
And Mid(sentence, Len(sentence) - Len(word) + 1, Len(word)) = word Then
Debug.Print "yes(3)"
End If
'-- Or sometimes you will see this, a tiny bit more efficient:
If Len(sentence) >= Len(word) _
And InStr(Len(sentence) - Len(word) + 1, sentence, word) Then
Debug.Print "yes(4)"
End If
'-- Finding all occurences is a snap:
r = InStr(1, sentence, word)
Do While r <> 0
Debug.Print r
r = InStr(r + 1, sentence, word)
Loop
End Sub
|
On Error Resume Next
'Ask for non-existent class to force error from CIMOM
Set t_Service = GetObject("winmgmts://./root/default")
Set t_Object = t_Service.Get("Nosuchclass000")
|
<reponame>npocmaka/Windows-Server-2003
'***************************************************************************
'This script tests the enumeration of subclasses using XML/HTTP
'***************************************************************************
On Error Resume Next
Dim objLocator
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
' Replace the first argument to this function with the URL of your WMI XML/HTTP server
' For the local machine, use the URL as below
Dim objService
Set objService = objLocator.ConnectServer("[http://calvinids/cimom]", "root\cimv2")
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
WScript.Echo objService.Get("win32_logicaldisk").Path_.Path
' Specify 2nd param of 1 0 here if you want sync
for each subclass in objService.instancesOf ("win32_process")
WScript.Echo subclass.Name
exit for
next
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
<filename>admin/wmi/wbem/scripting/test/registry/registry.vbs
'
' This sample illustrates how to retrieve registry data from WMI. Note that the accompanying MOF
' (registry.mof) must be compiled and loaded for this sample to run correctly.
'
on error resume next
set transports = GetObject("winmgmts:{impersonationLevel=impersonate}!root/registryScriptExample").InstancesOf ("RegTrans")
for each transport in transports
WScript.Echo "Transport " & transport.TransportsGUID & " has name [" & transport.Name & "] and Enabled=" _
& transport.Enabled
next
|
<reponame>LaudateCorpus1/RosettaCodeData
SUB Main()
' This is the start of the program
END
|
function gnomeSort( a )
dim i
dim j
i = 1
j = 2
do while i < ubound( a ) + 1
if a(i-1) <= a(i) then
i = j
j = j + 1
else
swap a(i-1), a(i)
i = i - 1
if i = 0 then
i = j
j = j + 1
end if
end if
loop
gnomeSort = a
end function
sub swap( byref x, byref y )
dim temp
temp = x
x = y
y = temp
end sub
|
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim timestamp As New SWbemDateTime
Dim newClass As SWbemObjectEx
Dim newProperty As SWbemProperty
Private Sub Form_Load()
'Create a new class
Set newClass = GetObject("winmgmts:root\default").Get
'Set the class name - we could do this via the Path_.Class
'property but instead we'll use the system property __CLASS
newClass.SystemProperties_("__CLASS").Value = "Archibald"
'Set the timestamp property
Set newProperty = newClass.SystemProperties_.Add("__TIMESTAMP", wbemCimtypeDatetime)
timestamp.SetVarDate (Now())
newProperty.Value = timestamp.Value
'Save the object
newClass.Put_
Set newClass = GetObject("winmgmts:root\default:Archibald")
timestamp.Value = newClass.SystemProperties_("__TIMESTAMP").Value
MsgBox timestamp.GetVarDate
End Sub
|
<gh_stars>1-10
Public Function Bin(ByVal l As Long) As String
Dim i As Long
If l Then
If l And &H80000000 Then 'negative number
Bin = "1" & String$(31, "0")
l = l And (Not &H80000000)
For i = 0 To 30
If l And (2& ^ i) Then
Mid$(Bin, Len(Bin) - i) = "1"
End If
Next i
Else 'positive number
Do While l
If l Mod 2 Then
Bin = "1" & Bin
Else
Bin = "0" & Bin
End If
l = l \ 2
Loop
End If
Else
Bin = "0" 'zero
End If
End Function
'testing:
Public Sub Main()
Debug.Print Bin(5)
Debug.Print Bin(50)
Debug.Print Bin(9000)
End Sub
|
'***********************************************************************
'*
'* WbemSink_OnCompleted
'*
'***********************************************************************
sub WbemSink_OnCompleted(hResult, pErrorObject, pAsyncContext)
end sub
'***********************************************************************
'*
'* WbemSink_OnObjectReady
'*
'***********************************************************************
sub WbemSink_OnObjectReady(pObject, pAsyncContext)
end sub
Dim Service
Dim MyObect
Set Service = GetObject ("Winmgmts:")
Set MySink = Wscript.CreateObject ("Wbemscripting.SWbemSink", "WbemSink_")
While True
'Set MyObject = Service.GetASync ("win32_Service")
Service.GetAsync MySink, "win32_Service"
Wend
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
s = "Rosetta"
s = s & " Code"
WScript.StdOut.Write s
|
<filename>Task/Hello-world-Standard-error/VBA/hello-world-standard-error.vba
Sub StandardError()
Debug.Print "Goodbye World!"
End Sub
|
<filename>admin/wmi/wbem/scripting/test/vb/errmsg/errmsg.frm
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
On Error Resume Next
'Ask for non-existant class to force error from CIMOM
Dim t_Service As SWbemServices
Dim t_Object As SWbemObject
Set t_Service = GetObject("winmgmts://./root/default")
Set t_Object = t_Service.Get("Nosuchclass000")
If Err = 0 Then
Debug.Print "Got a class"
Else
PrintErrorInfo
Set t_Object2 = CreateObject("WbemScripting.SWbemLastError")
If Err <> 0 Then
Debug.Print "Couldn't get last error again - as expected"
Err.Clear
Else
Debug.Print "Got the error object again - this shouldn't have happened!"
End If
'Force the error again
Set t_Object = t_Service.Get("Nosuchclass000")
If Err <> 0 Then
PrintErrorInfo
Err.Clear
Else
Debug.Print "Got a class"
End If
End If
End Sub
Sub PrintErrorInfo()
Debug.Print ""
Dim errObj As SWbemLastError
Debug.Print "Err Information:"
Debug.Print ""
Debug.Print " Source:", Err.Source
Debug.Print " Description:", Err.Description
Debug.Print " Number", Err.Number
Debug.Print " LastDllError", Err.LastDllError
'Create the last error object
Set errObj = CreateObject("WbemScripting.SWbemLastError")
Debug.Print ""
Debug.Print "WBEM Last Error Information:"
Debug.Print ""
Debug.Print " Operation:", errObj.Operation
Debug.Print " Provider:", errObj.ProviderName
strDescr = errObj.Description
strPInfo = errObj.ParameterInfo
strCode = errObj.StatusCode
If Not IsNull(strDescr) Then
Debug.Print " Description:", strDescr
End If
If Not IsNull(strPInfo) Then
Debug.Print " Parameter Info:", strPInfo
End If
If Not IsNull(strCode) Then
Debug.Print " Status:", strCode
End If
Err.Clear
Set errObj = Nothing
Debug.Print ""
End Sub
|
<reponame>npocmaka/Windows-Server-2003
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmInactivity
BorderStyle = 0 'None
Caption = "Inactivity Scale"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Visible = 0 'False
Begin TabDlg.SSTab SSTab1
Height = 5055
Left = 0
TabIndex = 3
TabStop = 0 'False
Top = 360
Width = 9405
_ExtentX = 16589
_ExtentY = 8916
_Version = 327681
Tabs = 1
TabsPerRow = 8
TabHeight = 794
ShowFocusRect = 0 'False
TabCaption(0) = "Inactivity Scale"
TabPicture(0) = "frmInactivity.frx":0000
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label7"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label6"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Label5"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Label4"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "Label3"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "Label2"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).Control(6)= "Label1"
Tab(0).Control(6).Enabled= 0 'False
Tab(0).Control(7)= "Combo1"
Tab(0).Control(7).Enabled= 0 'False
Tab(0).ControlCount= 8
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
ItemData = "frmInactivity.frx":001C
Left = 120
List = "frmInactivity.frx":002B
TabIndex = 1
Text = "Combo1"
Top = 600
Width = 9135
End
Begin VB.Label Label1
Caption = $"frmInactivity.frx":003A
Height = 495
Left = 360
TabIndex = 10
Top = 1560
Width = 8775
End
Begin VB.Label Label2
Caption = "3c,00,00,00 = 60 seconds = 1 minute"
Height = 255
Left = 360
TabIndex = 9
Top = 2160
Width = 8775
End
Begin VB.Label Label3
Caption = "0a,00,00,00 = 10 seconds"
Height = 255
Left = 360
TabIndex = 8
Top = 2520
Width = 8775
End
Begin VB.Label Label4
Caption = "01,00,00,00 = 1 second"
Height = 255
Left = 360
TabIndex = 7
Top = 2880
Width = 8775
End
Begin VB.Label Label5
Caption = "68,01,00,00 = 360 seconds = 6 minutes"
Height = 255
Left = 360
TabIndex = 6
Top = 3240
Width = 8775
End
Begin VB.Label Label6
Caption = "80,33,e1,01 = 31536000 seconds = 525600 minutes = 8760 hours = 365 days = 1 year"
Height = 255
Left = 360
TabIndex = 5
Top = 3600
Width = 8775
End
Begin VB.Label Label7
Caption = "Values must be input in seconds."
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 4
Top = 1080
Width = 8895
End
End
Begin VB.TextBox Text1
Height = 285
Left = 0
TabIndex = 0
Text = "HKR,, InactivityScale, 1, 0A,00,00,00"
Top = 0
Width = 9495
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 2
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 13070
Text = "InactivityTimeout * InactivityScale equals the inactivity timeout in seconds. "
TextSave = "InactivityTimeout * InactivityScale equals the inactivity timeout in seconds. "
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "5/12/98"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4:40 PM"
Key = ""
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmInactivity"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim HexValue As String
Dim PasteValue As String
Dim FirstBit As String
Dim SecondBit As String
Dim ThirdBit As String
Dim FourthBit As String
Const H As String = "&H"
Const Delim As String = ","
Dim Which As Integer
Public Sub EditCopy()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
Clipboard.Clear
Clipboard.SetText Text1.Text
End Sub
Public Sub EditPaste()
GetWord (Clipboard.GetText)
PasteValue = FirstBit & Delim & SecondBit & Delim & ThirdBit & Delim & FourthBit
UpdateCombo (PasteValue)
End Sub
Private Function UpdateCombo(Num As String)
PreVert (Num)
While Left(PreNum, 1) = "0"
PreNum = Mid(PreNum, 2)
Wend
Combo1.Text = CDec(H + PreNum)
Combo1_Click
End Function
Private Sub Combo1_Click()
HexValue = Combo1.Text
If HexValue = "" Then
HexValue = 0
End If
If HexValue > 100000000 Then
HexValue = 0
Combo1.Text = 0
End If
HexCon (HexValue)
HexValue = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, InactivityScale, 1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(HexValue)
Text1.SetFocus
End Sub
Private Sub Update()
Text1.Text = "HKR,, InactivityScale, 1, " & HexValue
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
HexCon (Combo1.Text)
HexValue = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, InactivityScale, 1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(HexValue)
Text1.SetFocus
End If
End Sub
Private Sub Form_Load()
Combo1.Text = "10"
StatusBar1.Panels(1).Text = "InactivityTimeout * InactivityScale equals the inactivity timeout in seconds."
ClearControl
End Sub
Public Sub GetWord(strString As String)
Dim strSubString As String
Dim lStart As Long
Dim lStop As Long
Dim One As String
lStart = 1
lStop = Len(strString)
While lStart < lStop And "," <> Mid$(strString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strString, lStop + 1, 1) And lStop <= Len(strString) ' Loop until second , found
lStop = lStop + 1
Wend
'Connect = Mid$(strString, lStart + 1, lStop - lStart) ' Grab word found between "'s
'cmbText.Text = Connect
strSubString = Mid$(strString, lStop + 2)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until third , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until fourth , found
lStop = lStop + 1
Wend
'One = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
'Clean (One)
'One = Right$(BNum, 1)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FirstBit = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FirstBit)
FirstBit = CleanNum
'PasteResponse (FirstByte)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
SecondBit = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (SecondBit)
SecondBit = CleanNum
'PasteCheck (SecondByte)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
ThirdBit = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (ThirdBit)
ThirdBit = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FourthBit = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FourthBit)
FourthBit = CleanNum
End Sub
Public Sub ClearControl()
HexValue = "0A,00,00,00"
PasteValue = ""
FirstBit = ""
SecondBit = ""
ThirdBit = ""
FourthBit = ""
Text1.Text = "HKR,, InactivityScale, 1, 0A,00,00,00"
Combo1.Text = "10"
Dim strFirst As String
strFirst = Len("HKR,, InactivityScale, 1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(HexValue)
If frmInactivity.Visible = False Then
frmInactivity.Visible = True
End If
Text1.SetFocus
End Sub
Private Sub Form_Resize()
Text1.Width = frmInactivity.Width
Combo1.Width = frmInactivity.Width - 370
SSTab1.Width = frmInactivity.Width - 75
SSTab1.Height = frmInactivity.Height - 675
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Clipboard.Clear
Clipboard.SetText Text1.Text
EditPaste
End If
End Sub
Private Sub Text1_Click()
Dim Start As Integer
Start = Text1.SelStart
If 24 < Start And Start < 38 Then
If Which = 1 Then Exit Sub
Text1.SelStart = 26
Text1.SelLength = 11
Text1.SetFocus
Which = 1
Else
Which = 0
End If
'MsgBox Start
End Sub
|
Attribute VB_Name = "CmdLineOptions"
Option Explicit
' i_strCommand is the command line.
' i_strOptionList is a comma separated list of options that we are looking for, eg
' "h,?,help" will look for /h, /?, /help
Public Function OptionExists( _
ByVal i_strCommand As String, _
ByVal i_strOptionList, _
ByVal i_blnIgnoreCase As Boolean _
) As Boolean
Dim arrCmdOptions() As String
Dim arrOptions() As String
Dim intCmdIndex As Long
Dim intOptionIndex As Long
Dim strOption As String
Dim strCmdWord As String
arrCmdOptions = Split(i_strCommand)
arrOptions = Split(i_strOptionList, ",")
For intOptionIndex = LBound(arrOptions) To UBound(arrOptions)
strOption = "/" & arrOptions(intOptionIndex)
If (i_blnIgnoreCase) Then
strOption = LCase$(strOption)
End If
For intCmdIndex = LBound(arrCmdOptions) To UBound(arrCmdOptions)
If (arrCmdOptions(intCmdIndex) <> "") Then
strCmdWord = arrCmdOptions(intCmdIndex)
If (i_blnIgnoreCase) Then
strCmdWord = LCase$(strCmdWord)
End If
If (strOption = strCmdWord) Then
OptionExists = True
Exit Function
End If
End If
Next
Next
OptionExists = False
End Function
' i_strCommand is the command line.
' i_strOptionList is a comma separated list of options that we are looking for, eg
' "i,input" will look for /i or /input. When one is found, the next word from
' the command line is returned. Multiple words enclosed in double quotes are
' considered a single word. The quotes are stripped.
' Eg GetOption("/abc def /ghi ""Hello World""", "ghi", True) returns Hello World
Public Function GetOption( _
ByVal i_strCommand As String, _
ByVal i_strOptionList, _
ByVal i_blnIgnoreCase As Boolean _
) As String
On Error GoTo LErrorHandler
Dim arrOptions() As String
Dim intIndex As Long
Dim strRemainingCmdLine As String
Dim strCurrentChar As String
Dim strCurrentWord As String
Dim strTerminatingChar As String
Dim strOption As String
Dim intPos As Long
Dim blnOptionFound As Boolean
strRemainingCmdLine = Trim$(i_strCommand)
arrOptions = Split(i_strOptionList, ",")
Do While (strRemainingCmdLine <> "")
strCurrentChar = Mid$(strRemainingCmdLine, 1, 1)
Select Case strCurrentChar
Case """"
strTerminatingChar = """"
Case Else
strTerminatingChar = " "
End Select
' Where does this word end? Start is 2, because we don't want
' the search to stop at the current character.
intPos = InStr(2, strRemainingCmdLine, strTerminatingChar)
If intPos = 0 Then
intPos = Len(strRemainingCmdLine) + 1
End If
If (strTerminatingChar = """") Then
' Eat the terminating double quotes too.
intPos = intPos + 1
End If
strCurrentWord = Mid$(strRemainingCmdLine, 1, intPos - 1)
strRemainingCmdLine = Trim$(Mid$(strRemainingCmdLine, intPos))
If blnOptionFound Then
If strCurrentChar = "/" Then
' strCurrentWord represents the next option. The desired option
' was not followed by any non-option word.
GetOption = ""
Else
If (strTerminatingChar = """") Then
' Strip out the enclosing double quotes
GetOption = Mid$(strCurrentWord, 2, Len(strCurrentWord) - 2)
Else
GetOption = strCurrentWord
End If
End If
Exit Function
End If
If (i_blnIgnoreCase) Then
strCurrentWord = LCase$(strCurrentWord)
End If
For intIndex = LBound(arrOptions) To UBound(arrOptions)
strOption = "/" & arrOptions(intIndex)
If (i_blnIgnoreCase) Then
strOption = LCase$(strOption)
End If
If (strOption = strCurrentWord) Then
blnOptionFound = True
End If
Next
Loop
Exit Function
LErrorHandler:
GetOption = ""
End Function
|
For h = 1 To 20
WScript.StdOut.Write "H(" & h & ") = " & Hamming(h)
WScript.StdOut.WriteLine
Next
WScript.StdOut.Write "H(" & 1691 & ") = " & Hamming(1691)
WScript.StdOut.WriteLine
Function Hamming(l)
Dim h() : Redim h(l) : h(0) = 1
i = 0 : j = 0 : k = 0
x2 = 2 : x3 = 3 : x5 = 5
For n = 1 To l-1
m = x2
If m > x3 Then m = x3 End If
If m > x5 Then m = x5 End If
h(n) = m
If m = x2 Then i = i + 1 : x2 = 2 * h(i) End If
If m = x3 Then j = j + 1 : x3 = 3 * h(j) End If
If m = x5 Then k = k + 1 : x5 = 5 * h(k) End If
Next
Hamming = h(l-1)
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData
Function catalan(n)
catalan = factorial(2*n)/(factorial(n+1)*factorial(n))
End Function
Function factorial(n)
If n = 0 Then
Factorial = 1
Else
For i = n To 1 Step -1
If i = n Then
factorial = n
Else
factorial = factorial * i
End If
Next
End If
End Function
'Find the first 15 Catalan numbers.
For j = 1 To 15
WScript.StdOut.Write j & " = " & catalan(j)
WScript.StdOut.WriteLine
Next
|
<gh_stars>10-100
'
' test1.vbs
'
' test string manipulation
'
Dim WshSHell
Dim DevConStrings
Dim String
Dim Count
Dim i
set WshShell = WScript.CreateObject("WScript.Shell")
set DevConStrings = WScript.CreateObject("DevCon.Strings")
DevConStrings.Add "Alpha"
DevConStrings.Add "Beta"
DevConStrings.Add "Gamma"
DevConStrings.Add "Delta"
Count = DevConStrings.Count
Wscript.Echo "Count="+CStr(Count)
FOR EACH String In DevConStrings
WScript.Echo String
NEXT
DevConStrings.Remove 2
Count = DevConStrings.Count
Wscript.Echo "Count="+CStr(Count)
For i = 1 To Count
String = DevConStrings(i)
WScript.Echo String
NEXT
DevConStrings.Insert 2,"Beta2"
Count = DevConStrings.Count
Wscript.Echo "Count="+CStr(Count)
For i = 1 To Count
String = DevConStrings(i)
WScript.Echo String
NEXT
|
<reponame>npocmaka/Windows-Server-2003
on error resume next
set service = GetObject("winmgmts:{impersonationLevel=impersonate}!Win32_Service=""SNMP""")
service.StopService ()
if err <>0 then
WScript.Echo Hex(Err.Number)
end if
|
<gh_stars>0
/*
----------------------------------------------------------------------------------
- -
- Copyright Mentor Graphics Corporation -
- All Rights Reserved -
- -
- THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY -
- INFORMATION WHICH IS THE PROPERTY OF MENTOR GRAPHICS -
- CORPORATION OR ITS LICENSORS AND IS SUBJECT -
- TO LICENSE TERMS. -
- -
----------------------------------------------------------------------------------
- File created by: membistipGenerate -
- Version: 2017.1 -
- Created on: Sat Feb 23 20:09:40 CST 2019 -
----------------------------------------------------------------------------------
*/
`timescale 100 ps / 10 ps
module READONLY_LVISION_MEM0_INTERFACE_MISR_STRAP (
MISR_IN,
MISR_INB,
MISR_SIGNATURE
);
input [31:0] MISR_IN;
input [31:0] MISR_INB;
output [31:0] MISR_SIGNATURE;
assign MISR_SIGNATURE[0] = MISR_IN[0];
assign MISR_SIGNATURE[1] = MISR_IN[1];
assign MISR_SIGNATURE[2] = MISR_IN[2];
assign MISR_SIGNATURE[3] = MISR_IN[3];
assign MISR_SIGNATURE[4] = MISR_IN[4];
assign MISR_SIGNATURE[5] = MISR_IN[5];
assign MISR_SIGNATURE[6] = MISR_INB[6];
assign MISR_SIGNATURE[7] = MISR_INB[7];
assign MISR_SIGNATURE[8] = MISR_INB[8];
assign MISR_SIGNATURE[9] = MISR_INB[9];
assign MISR_SIGNATURE[10] = MISR_IN[10];
assign MISR_SIGNATURE[11] = MISR_INB[11];
assign MISR_SIGNATURE[12] = MISR_INB[12];
assign MISR_SIGNATURE[13] = MISR_IN[13];
assign MISR_SIGNATURE[14] = MISR_INB[14];
assign MISR_SIGNATURE[15] = MISR_INB[15];
assign MISR_SIGNATURE[16] = MISR_INB[16];
assign MISR_SIGNATURE[17] = MISR_IN[17];
assign MISR_SIGNATURE[18] = MISR_INB[18];
assign MISR_SIGNATURE[19] = MISR_IN[19];
assign MISR_SIGNATURE[20] = MISR_INB[20];
assign MISR_SIGNATURE[21] = MISR_IN[21];
assign MISR_SIGNATURE[22] = MISR_IN[22];
assign MISR_SIGNATURE[23] = MISR_IN[23];
assign MISR_SIGNATURE[24] = MISR_IN[24];
assign MISR_SIGNATURE[25] = MISR_IN[25];
assign MISR_SIGNATURE[26] = MISR_INB[26];
assign MISR_SIGNATURE[27] = MISR_INB[27];
assign MISR_SIGNATURE[28] = MISR_INB[28];
assign MISR_SIGNATURE[29] = MISR_IN[29];
assign MISR_SIGNATURE[30] = MISR_INB[30];
assign MISR_SIGNATURE[31] = MISR_IN[31];
endmodule
|
'
' Script to update OS install MSI package
' Syntax: cscript OsPack.vbs package_path platform product_number_major product_number_minor build_number_major build_number_minor language_number info_file
'
'
Sub Usage()
Wscript.echo "Script to update OS install MSI package. Syntax:"
Wscript.echo " cscript OsPack.vbs package_path platform product_number build_number language_number"
Wscript.echo " package_path - path to package to update. requires read/write access"
Wscript.echo " platform - must be either 'Alpha' or 'Intel'"
Wscript.echo " product_number_major - 1 digit major build number of the current build, i.e 5"
Wscript.echo " product_number_minor - 1 digit minor build number of the current build, i.e 2"
Wscript.echo " build_number_major - 4 digit major build number of the current build, i.e 2600"
Wscript.echo " build_number_minor - 4 digit minor build number of the current build, i.e 1001"
Wscript.echo " language_number - Language Id of the desired language, i.e. 1033 = US English, 0=Neutral"
Wscript.echo " info_file - File containing information in Valuename = Value format"
Wscript.Quit -1
End Sub
' takes a string of the form 0x409 and converts it to an int
Function IntFromHex(szInHexString)
szHexString = szInHexString
IntFromHex = 0
multiplier = 1
While (UCase(Right(szHexString, 1)) <> "X")
Ch = UCase(Right(szHexString, 1))
Select Case Ch
Case "A" Ch = 10
Case "B" Ch = 11
Case "C" Ch = 12
Case "D" Ch = 13
Case "E" Ch = 14
Case "F" Ch = 15
End Select
IntFromHex = IntFromHex + multiplier * Ch
multiplier = multiplier * 16
szHexString = Left(szHexString, Len(szHexString) - 1)
Wend
Exit Function
End Function
'
' Uses uuidgen.exe to generate a GUID, then formats it to be
' a MSI acceptable string guid
'
' This makes use of a temporary file %temp%\MakeTempGUID.txt
'
Function MakeGuid()
Dim WSHShell, FileSystem, File, ret, TempFileName, regEx
Set WSHShell = CreateObject("WScript.Shell")
Set FileSystem = CreateObject("Scripting.FileSystemObject")
TempFileName = WSHShell.ExpandEnvironmentStrings("%temp%\MakeTempGUID.txt")
If FileSystem.fileExists(TempFileName) Then
FileSystem.DeleteFile TempFileName
End If
ret = WSHShell.Run("uuidgen -o" & TempFileName, 2, True)
If FileSystem.fileExists(TempFileName) Then
Set File = FileSystem.OpenTextFile(TempFileName, 1)
MakeGuid = "{" & UCase(File.ReadLine) & "}"
File.Close
FileSystem.DeleteFile TempFileName
Wscript.echo " Generated GUID: " & MakeGuid
Else
MakeGuid = "{00000000-0000-0000-0000-000000000000}"
Wscript.echo " ERROR: Failed to generate GUID"
End If
Exit Function
End Function
Function GetToken(szFile, szValue)
Dim FileSystem, File, Line, regEx, Matches, Match
GetToken = Empty
Set FileSystem = CreateObject("Scripting.FileSystemObject")
If Err <> 0 Then
Wscript.echo "ERROR: Error creating filesystem object"
End If
szPathToFile = FileSystem.GetAbsolutePathName(szFile) ' Gets current directory
If FileSystem.fileExists(szPathToFile) Then
Set File = FileSystem.OpenTextFile(szPathToFile, 1) 'Open up the file
If Err <> 0 Then
Wscript.echo "ERROR: Error opening file " & szPathToFile
End If
Do While File.AtEndOfStream <> True
Line = File.ReadLine
Set regEx = New RegExp
If Err <> 0 Then
Wscript.echo "ERROR: Error creating RegExp object"
End If
regEx.Pattern = szValue & " *=+ *" ' Look for valuename = Value entry
regEx.IgnoreCase = False
regEx.Global = False
Set Matches = regEx.Execute(Line)
For Each Match In Matches
ValueIndex = Match.FirstIndex + Match.Length + 1
GetToken = Mid(Line, ValueIndex)
Exit Function
Next
Loop
If Matches.Count = 0 Then
Wscript.echo "Error: Could not find " & szValue & " in " & szFile
End If
Else
Wscript.echo "ERROR: " & szPathToFile & " not present"
End If
Exit Function
End Function
'
' Updates the OS install MSI package using the following paramaters
' szPackage - path to package to update. requires read/write access
' szPlatform - must be either "Alpha" or "Intel"
' dwProductNumberMajor - 1 digit build number of the current product, i.e 5
' dwProductNumberMinor - 1 digit build number of the current build, i.e 1
' dwBuildNumberMajor - 4 digit build number of the current build, i.e 2600
' dwBuildNumberMinor - 4 digit build number of the current build, i.e 1001
' dwLanguage - Language Id of the desired language, i.e. 1033 = US English, 0=Neutral
'
Function UpdateOsPackage(szPackage, szPlatform, dwProductNumberMajor, dwProductNumberMinor, dwBuildNumberMajor, dwBuildNumberMinor, dwLanguage, szInfoFile)
Dim WSHShell, Installer, Database, SummaryInfo, Record, View, SQL
Wscript.echo "Updating OS install package: " & szPackage
Wscript.echo " For: " & szPlatform
Wscript.echo " Product: " & dwProductNumberMajor & "." & dwProductNumberMinor
Wscript.echo " Build: " & dwBuildNumberMajor & "." & dwBuildNumberMinor
Wscript.echo " Lang: " & dwLanguage
UpdateOsPackage = 0
Err = 0
On Error Resume Next
'Create the MSI API object
Set Installer = CreateObject("WindowsInstaller.Installer")
If Err <> 0 Then
Err = 0
Set Installer = CreateObject("WindowsInstaller.Application")
End If
If Err <> 0 Then
Err = 0
Set Installer = CreateObject("Msi.ApiAutomation")
End If
If Err <> 0 Then
Err = 0
Wscript.echo "ERROR: Error creating Installer object"
UpdateOsPackage = -1
Exit Function
End If
'Create the WSH shell object
Set WSHShell = CreateObject("WScript.Shell")
If Err <> 0 Then
Wscript.echo "ERROR: Error creating WSHShell object"
UpdateOsPackage = -1
Exit Function
End If
'Open the package
Set Database = Installer.OpenDatabase(szPackage, 1)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening database"
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Database opened for update"
'Generate and set a new package code
Set SummaryInfo = Database.SummaryInformation(3)
If Err <> 0 Then
Wscript.echo "ERROR: Creating Summary Info Object"
UpdateOsPackage = -1
Exit Function
End If
'-------------------------------------------------
' Remove the not needed Summary fields
'-------------------------------------------------
SummaryInfo.Property(3) = Empty 'Subject
SummaryInfo.Property(4) = Empty 'Author
SummaryInfo.Property(5) = Empty 'Keywords
SummaryInfo.Property(6) = Empty 'Comments
SummaryInfo.Property(8) = Empty 'Last Saved by
SummaryInfo.Property(13) = Empty 'Last Save Time
Err=0
SummaryInfo.Property(9) = MakeGuid()
If Err <> 0 Then
Wscript.echo "ERROR: Error setting package code"
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Updated package Code"
'-------------------------------------------------
'Update Platform and Language list
'-------------------------------------------------
SummaryInfo.Property(7) = szPlatform & ";" & dwLanguage
If Err <> 0 Then
Wscript.echo "ERROR: Error setting platform and language list"
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Updated Language and platform list to: " & szPlatform & ";" & dwLanguage
'-------------------------------------------------
'Get Product Name from szInfoFile and Set
'-------------------------------------------------
szProductName = GetToken(szInfoFile, "ProductName")
If IsEmpty(szProductName) Then
Wscript.echo "ERROR: Error getting Product Name from " & szInfoFile
UpdateOsPackage = -1
Exit Function
End If
SummaryInfo.Property(2) = szProductName
If Err <> 0 Then
Wscript.echo "ERROR: Error setting productname property"
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Updated Product Name to: " & szProductName
SummaryInfo.Persist
If Err <> 0 Then
Wscript.echo "ERROR: Error persisting summary info"
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " persisted summary stream"
SQL = "UPDATE Property SET Property.Value = '" & szProductName & "' WHERE Property.Property= 'ProductName'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " ProductName Property updated"
'-------------------------------------------------
'Generate and set a new product code
'-------------------------------------------------
SQL = "UPDATE Property SET Property.Value = '" & MakeGuid() & "' WHERE Property.Property= 'ProductCode'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " ProductCode Property updated"
'-------------------------------------------------
'set package Build
'-------------------------------------------------
SQL = "UPDATE Property SET Property.Value = '" & dwBuildNumberMajor & "." & dwBuildNumberMinor & "' WHERE Property.Property= 'PackageBuild'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " PackageBuild Property updated to: " & dwBuildNumberMajor & "." & dwBuildNumberMinor
'-------------------------------------------------
'Set the product language property
'-------------------------------------------------
SQL = "UPDATE Property SET Property.Value = '" & dwLanguage & "' WHERE Property.Property= 'ProductLanguage'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Product Language Property updated"
'-------------------------------------------------
'Set the product version property
'-------------------------------------------------
'
SQL = "UPDATE Property SET Property.Value = '" & dwProductNumberMajor & "." & dwProductNumberMinor & "." & dwBuildNumberMajor & "." & dwBuildNumberMinor & "' WHERE Property.Property= 'ProductVersion'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " ProductVersion Property updated to: " & dwProductNumberMajor & "." & dwProductNumberMinor & "." & dwBuildNumberMajor & "." & dwBuildNumberMinor
'-------------------------------------------------
'Set the DialogCaption property
'-------------------------------------------------
'
szDialogCaption = GetToken(szInfoFile, "DialogCaption")
If IsEmpty(szDialogCaption) Then
Wscript.echo "ERROR: Error getting DialogCaption from " & szInfoFile
UpdateOsPackage = -1
Exit Function
End If
SQL = "UPDATE Property SET Property.Value = '" & szDialogCaption & "' WHERE Property.Property= 'DialogCaption'"
Set View = Database.OpenView(SQL)
If Err <> 0 Then
Wscript.echo "ERROR: Error opening view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
View.Execute
If Err <> 0 Then
Wscript.echo "ERROR: Error executing view: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " DialogCaption Property updated"
'-------------------------------------------------
'Set the DiskPrompt property
'-------------------------------------------------
'
'szDiskPrompt = GetToken(szInfoFile, "DiskPrompt")
'If IsEmpty(szDiskPrompt) Then
' Wscript.echo "ERROR: Error getting DiskPrompt from " & szInfoFile
' UpdateOsPackage = -1
' Exit Function
'End If
'
'SQL = "UPDATE Property SET Property.Value = '" & szDiskPrompt & "' WHERE Property.Property= 'DiskPrompt'"
'Set View = Database.OpenView(SQL)
' If Err <> 0 Then
' Wscript.echo "ERROR: Error opening view: " & SQL
' UpdateOsPackage = -1
' Exit Function
'End If
'View.Execute
'If Err <> 0 Then
' Wscript.echo "ERROR: Error executing view: " & SQL
' UpdateOsPackage = -1
' Exit Function
'End If
'Wscript.echo " DiskPrompt Property updated"
'Commit changes
Database.Commit
If Err <> 0 Then
Wscript.echo "ERROR: Error commiting changes: " & SQL
UpdateOsPackage = -1
Exit Function
End If
Wscript.echo " Changes commited"
End Function
' main()
Set Args = Wscript.Arguments
Set FileSystem = CreateObject("Scripting.FileSystemObject")
If Args.Count <> 8 Then
Usage
End If
szPathToPackage = Args(0)
If Not FileSystem.fileExists(szPathToPackage) Then
Wscript.echo " invalid path: " & szPathToPackage
Usage
End If
szPlatform = Args(1)
If (UCase(szPlatform) = "INTEL") Or (UCase(szPlatform) = "X86") Or (UCase(szPlatform) = "I386") Or (UCase(szPlatform) = "IA64") Or (UCase(szPlatform) = "AMD64") Then
szPlatform = "Intel"
ElseIf (UCase(szPlatform) = "ALPHA") Or (UCase(szPlatform) = "AXP64") Then
szPlatform = "Alpha"
Else
Wscript.echo " invalid pltform: " & szPlatform
Usage
End If
dwProdMaj = Args(2)
If Not IsNumeric(dwProdMaj) Then
Wscript.echo " invalid major product number: " & dwProdMaj
Usage
End If
dwProdMin = Args(3)
If Not IsNumeric(dwProdMin) Then
Wscript.echo " invalid minor product number: " & dwProdMin
Usage
End If
dwBuildMaj = Args(4)
If Not IsNumeric(dwBuild) Then
Wscript.echo " invalid major build number: " & dwBuildMaj
Usage
End If
dwBuildMin = Args(5)
If Not IsNumeric(dwBuild) Then
Wscript.echo " invalid minor build number: " & dwBuildMin
Usage
End If
dwLang = Args(6)
If Not IsNumeric(dwLang) Then
If Not IsNumeric(IntFromHex(dwLang)) Then
Wscript.echo " invalid Language: " & dwLang
Usage
Else
dwLang = IntFromHex(dwLang)
End If
End If
szInfoFile = Args(7)
Wscript.echo szPathToPackage, szPlatform, Int(dwProdMaj),Int(dwProdMin), Int(dwBuildMaj), Int(dwBuildMin), dwLang, szInfoFile
Status = UpdateOsPackage(szPathToPackage, szPlatform, Int(dwProdMaj),Int(dwProdMin), Int(dwBuildMaj), Int(dwBuildMin), dwLang, szInfoFile)
Wscript.Quit Status
|
<filename>admin/pchealth/authtools/prodtools/common/logging.bas
Attribute VB_Name = "Logging"
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const WM_VSCROLL = &H115
Private Const SB_LINEDOWN = &H1
Private Const EM_SETSEL = &HB1
Private Const EM_REPLACESEL = &HC2
Private p_strLogFile As String
Private p_strTID As String
Public Enum LOGGING_TYPE_E
LOGGING_TYPE_NORMAL_E = 0
LOGGING_TYPE_ERROR_E = 1
LOGGING_TYPE_WARNING_E = 2
End Enum
Public Sub SetLogFile( _
Optional ByVal i_strLogFile As String = "" _
)
If (Trim$(i_strLogFile) = "") Then
p_strLogFile = Environ$("TEMP") & "\" & App.Title & ".log"
Else
p_strLogFile = i_strLogFile
End If
p_strTID = App.ThreadID
End Sub
Public Sub WriteLog( _
ByVal i_str As String, _
Optional ByVal i_blnPlain As Boolean = False, _
Optional ByVal i_blnUnicode As Boolean = False _
)
If (i_blnPlain) Then
FileWrite p_strLogFile, i_str & vbCrLf, True, i_blnUnicode
Else
FileWrite p_strLogFile, "[" & p_strTID & "] " & Date & " " & Time & " > " & _
i_str & vbCrLf, True, i_blnUnicode
End If
End Sub
Public Function GetLogFileName() As String
GetLogFileName = p_strLogFile
End Function
Public Sub OutputToTextBox( _
ByVal i_txt As TextBox, _
ByVal i_str As String _
)
SendMessage i_txt.hwnd, EM_SETSEL, &H7FFFFFFF, &H7FFFFFFF
DoEvents
SendMessage i_txt.hwnd, EM_REPLACESEL, 0, i_str & vbCrLf
DoEvents
SendMessage i_txt.hwnd, WM_VSCROLL, SB_LINEDOWN, ""
DoEvents
End Sub
' We have i_enumLoggingType so that someone who calls this program from the command line can
' search for errors and warnings in the log file once the program terminates. Otherwise, how
' will they know that it failed?
Public Sub OutputToTextBoxAndWriteLog( _
ByVal i_txt As TextBox, _
ByVal i_str As String, _
ByVal i_enumLoggingType As LOGGING_TYPE_E _
)
Dim str As String
Select Case (i_enumLoggingType)
Case LOGGING_TYPE_NORMAL_E
str = i_str
Case LOGGING_TYPE_ERROR_E
str = "Error: " & i_str
Case LOGGING_TYPE_WARNING_E
str = "Warning: " & i_str
End Select
OutputToTextBox i_txt, str
WriteLog str, True, True
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
If objRS.RecordCount > 0 Then
For Each objUser in ObjRS
WScript.Echo objRS.Fields("DistinguishedName")
Next
End If
|
<filename>Task/Comments/VBScript/comments.vb
' This is a VBScript comment
|
'mung.vbs
option explicit
sub mung(c)
dim n
n=c+1
wscript.echo "[Level",n & "] Mung until no good"
on error resume next
mung n
on error goto 0
wscript.echo "[Level",n & "] no good"
end sub
mung 0
|
'
L_Welcome_MsgBox_Message_Text = "This script demonstrates how to rename snapin items from scriptable objects."
L_Welcome_MsgBox_Title_Text = "Windows Scripting Host Sample"
Call Welcome()
' ********************************************************************************
Dim mmc
Dim doc
Dim snapins
Dim frame
Dim views
Dim view
Dim scopenamespace
Dim rootnode
Dim Nodes
Dim scopenode
Dim SnapNode
Dim ResultItem
Dim MySnapin
' Following are snapin exposed objects.
Dim ScopeNodeObject
Dim ResultItemObject
'get the various objects we'll need
Set mmc = wscript.CreateObject("MMC20.Application")
Set frame = mmc.Frame
Set doc = mmc.Document
Set namespace = doc.ScopeNamespace
Set rootnode = namespace.GetRoot
Set views = doc.views
Set view = views(1)
Set snapins = doc.snapins
snapins.Add "{975797FC-4E2A-11D0-B702-00C04FD8DBF7}" ' eventlog snapin
snapins.Add "{C3D863FF-5135-4CFC-8C11-E7396DA15D03}" ' Multisel sample
' Get rootnode of the snapin.
Set SnapNode1 = namespace.GetChild(rootnode)
' Select the root node of the snapin.
view.ActiveScopeNode = SnapNode1
' Get "Application Log" and rename it (R-Click to rename).
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.RenameScopeNode "Test Log", SnapNode1
WScript.Sleep 1000
' Select "Application Log" and rename it.
view.ActiveScopeNode = SnapNode1
view.RenameScopeNode "New Test Log"
WScript.Sleep 1000
' Select the "System Log" in List View & rename it.
' Eventviewer throws an exception while trying to
' rename scope item in ListView.
view.Select view.ListItems.Item(1)
'view.RenameSelectedItem "Test2 Log"
WScript.Sleep 1000
' Now enumerate and select the "Space Station" node in multi-sel sample.
Set SnapNode1 = namespace.GetChild(rootnode) ' Get the index snapin root
Set SnapNode1 = namespace.GetNext(SnapNode1) ' Get multi-sel root
view.ActiveScopeNode = SnapNode1
' Get the 4th child of multi-sel root node
Set SnapNode1 = namespace.GetChild(SnapNode1)
Set SnapNode1 = namespace.GetNext(SnapNode1)
Set SnapNode1 = namespace.GetNext(SnapNode1)
Set SnapNode1 = namespace.GetNext(SnapNode1)
view.ActiveScopeNode = SnapNode1
' Get the child of this "Space Vehicles" node and select it.
Set SnapNode1 = namespace.GetChild(SnapNode1)
view.ActiveScopeNode = SnapNode1
Set Nodes = view.ListItems
view.Select Nodes(1)
view.RenameSelectedItem "New Rocket0"
view.Deselect Nodes(1)
WScript.Sleep 1000
view.Select Nodes(2)
view.RenameSelectedItem "New Rocket2"
WScript.Sleep 1000
view.Select Nodes(3)
Set mmc = Nothing
' ********************************************************************************
' *
' * 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
|
<filename>admin/wmi/wbem/scripting/test/vbscript/locale.vbs
' Set the locale and check display name is OK
WScript.Echo "Pass 1 - Set locale in SWbemObjectPath"
WScript.Echo "======================================"
WScript.Echo
set obj = CreateObject ("WbemScripting.SWbemObjectPath")
obj.Security_.impersonationLevel = 3
obj.Server = "myServer"
obj.Namespace = "root\default"
obj.Locale = "ms_0x409"
WScript.Echo obj.Locale
WScript.Echo obj.DisplayName
WScript.Echo
WScript.Echo
'Now feed the display name the object
WScript.Echo "Pass 2 - Set locale in Display Name"
WScript.Echo "==================================="
WScript.Echo
obj.DisplayName = "winmgmts:[locale=ms_0x409]!root\splodge"
WScript.Echo obj.Locale
WScript.Echo obj.DisplayName
WScript.Echo
WScript.Echo
'Now Set locale direct
WScript.Echo "Pass 3 - Set locale directly"
WScript.Echo "============================"
WScript.Echo
obj.DisplayName = "winmgmts:root\splodge"
obj.Locale = "ms_0x408"
WScript.Echo obj.Locale
WScript.Echo obj.DisplayName
obj.Locale = vbNullString
WScript.Echo obj.Locale
WScript.Echo obj.DisplayName
obj.Locale = ""
WScript.Echo obj.Locale
WScript.Echo obj.DisplayName
WScript.Echo
WScript.Echo
'Plug the locale into the moniker
WScript.Echo "Pass 4 - Set locale in moniker"
WScript.Echo "============================="
WScript.Echo
set Service = GetObject ("winmgmts:[locale=ms_0x409]!root\default")
set cim = Service.Get ("__cimomidentification=@")
WScript.Echo cim.Path_.Locale
WScript.Echo cim.Path_.DisplayName
WScript.Echo
WScript.Echo
'Plug the locale into ConnectServer
WScript.Echo "Pass 4 - Set locale in ConnectServer"
WScript.Echo "===================================="
WScript.Echo
set Locator = CreateObject ("WbemScripting.SWbemLocator")
set Service = Locator.ConnectServer (,,,,"ms_0x409")
Service.Security_.impersonationLevel = 3
set disk = Service.Get ("Win32_LogicalDisk=""C:""")
WScript.Echo disk.Path_.locale
WScript.Echo disk.Path_.DisplayName
WScript.Echo
WScript.Echo
|
' starts the Configure DNS Server Wizard using MMC automation interfaces
option explicit
Dim mmc
Set mmc = CreateObject("MMC20.Application")
' uncomment this to cause the MMC console to appear
'Dim frame
'Set frame = mmc.Frame
'frame.restore
Dim doc
Set doc = mmc.Document
Dim namespace
Set namespace = doc.ScopeNamespace
Dim snapins
Set snapins = doc.snapins
Dim snapin
const DNS_SNAPIN_CLSID = "{2FAEBFA2-3F1A-11D0-8C65-00C04FD8FECB}"
' if DNS is not installed, this will fail.
set snapin = snapins.Add(DNS_SNAPIN_CLSID)
Dim views
Set views = doc.views
Dim view
Set view = views(1)
Dim rootnode
Set rootnode = namespace.GetRoot
View.ActiveScopeNode = namespace.GetChild(rootnode)
View.ActiveScopeNode = namespace.GetChild(View.ActiveScopeNode)
Dim menu
Set menu = view.ScopeNodeContextMenu
Dim menuItem
Set menuItem = menu.item(2)
menuItem.Execute
doc.Close(FALSE)
|
Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private Function identity(x As Long) As Long
For j = 0 To 1000
identity = x
Next j
End Function
Private Function sum(ByVal num As Long) As Long
Dim t As Long
For j = 0 To 1000
t = num
For i = 0 To 10000
t = t + i
Next i
Next j
sum = t
End Function
Private Sub time_it()
Dim start_time As Long, finis_time As Long
start_time = GetTickCount
identity 1
finis_time = GetTickCount
Debug.Print "1000 times Identity(1) takes "; (finis_time - start_time); " milliseconds"
start_time = GetTickCount
sum 1
finis_time = GetTickCount
Debug.Print "1000 times Sum(1) takes "; (finis_time - start_time); " milliseconds"
End Sub
|
Function Factors(x As Integer) As String
Application.Volatile
Dim i As Integer
Dim cooresponding_factors As String
Factors = 1
corresponding_factors = x
For i = 2 To Sqr(x)
If x Mod i = 0 Then
Factors = Factors & ", " & i
If i <> x / i Then corresponding_factors = x / i & ", " & corresponding_factors
End If
Next i
If x <> 1 Then Factors = Factors & ", " & corresponding_factors
End Function
|
Sub truncate(fpath,n)
'Check if file exist
Set objfso = CreateObject("Scripting.FileSystemObject")
If objfso.FileExists(fpath) = False Then
WScript.Echo fpath & " does not exist"
Exit Sub
End If
content = ""
'stream the input file
Set objinstream = CreateObject("Adodb.Stream")
With objinstream
.Type = 1
.Open
.LoadFromFile(fpath)
'check if the specified size is larger than the file content
If n <= .Size Then
content = .Read(n)
Else
WScript.Echo "The specified size is larger than the file content"
Exit Sub
End If
.Close
End With
'write the truncated version
Set objoutstream = CreateObject("Adodb.Stream")
With objoutstream
.Type = 1
.Open
.Write content
.SaveToFile fpath,2
.Close
End With
Set objinstream = Nothing
Set objoutstream = Nothing
Set objfso = Nothing
End Sub
'testing
Call truncate("C:\temp\test.txt",30)
|
Function StartsWith(s1,s2)
StartsWith = False
If Left(s1,Len(s2)) = s2 Then
StartsWith = True
End If
End Function
Function Contains(s1,s2)
Contains = False
If InStr(1,s1,s2) Then
Contains = True & " at positions "
j = 1
Do Until InStr(j,s1,s2) = False
Contains = Contains & InStr(j,s1,s2) & ", "
If j = 1 Then
If Len(s2) = 1 Then
j = j + InStr(j,s1,s2)
Else
j = j + (InStr(j,s1,s2) + (Len(s2) - 1))
End If
Else
If Len(s2) = 1 Then
j = j + ((InStr(j,s1,s2) - j) + 1)
Else
j = j + ((InStr(j,s1,s2) - j) + (Len(s2) - 1))
End If
End If
Loop
End If
End Function
Function EndsWith(s1,s2)
EndsWith = False
If Right(s1,Len(s2)) = s2 Then
EndsWith = True
End If
End Function
WScript.StdOut.Write "Starts with test, 'foo' in 'foobar': " & StartsWith("foobar","foo")
WScript.StdOut.WriteLine
WScript.StdOut.Write "Contains test, 'o' in 'fooooobar': " & Contains("fooooobar","o")
WScript.StdOut.WriteLine
WScript.StdOut.Write "Ends with test, 'bar' in 'foobar': " & EndsWith("foobar","bar")
|
on error resume next
set objArgs = wscript.Arguments
if objArgs.count < 1 then
wscript.echo "Usage setDriveLetter <driveletter>:"
wscript.quit(1)
end if
strDriveLetter = objArgs(0)
'// Get the volume
strQuery = "select * from Win32_Volume where DriveLetter = '" & strDriveLetter & "'"
set VolumeSet = GetObject("winmgmts:").ExecQuery(strQuery)
for each obj in VolumeSet
set Volume = obj
exit for
next
wscript.echo "DriveLetter: " & strDriveLetter
Volume.DriveLetter = Null
Volume.Put_
if Err.Number <> 0 then
Set objLastError = CreateObject("wbemscripting.swbemlasterror")
wscript.echo("Provider: " & objLastError.ProviderName)
wscript.echo("Operation: " & objLastError.Operation)
wscript.echo("Description: " & objLastError.Description)
wscript.echo("StatusCode: 0x" & Hex(objLastError.StatusCode))
end if
|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
Begin VB.Form frmMain
Caption = "VB MetaEdit"
ClientHeight = 6060
ClientLeft = 165
ClientTop = 735
ClientWidth = 8745
LinkTopic = "Form1"
ScaleHeight = 6060
ScaleWidth = 8745
StartUpPosition = 3 'Windows Default
Begin ComctlLib.Toolbar tbToolBar
Align = 1 'Align Top
Height = 420
Left = 0
TabIndex = 1
Top = 0
Width = 8745
_ExtentX = 15425
_ExtentY = 741
Appearance = 1
ImageList = "imlIcons"
_Version = 327680
BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7}
NumButtons = 14
BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Back"
Object.ToolTipText = "1036"
Object.Tag = ""
ImageIndex = 1
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Forward"
Object.ToolTipText = "1037"
Object.Tag = ""
ImageIndex = 2
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Cut"
Object.ToolTipText = "1038"
Object.Tag = ""
ImageIndex = 3
EndProperty
BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Copy"
Object.ToolTipText = "1039"
Object.Tag = ""
ImageIndex = 4
EndProperty
BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Paste"
Object.ToolTipText = "1040"
Object.Tag = ""
ImageIndex = 5
EndProperty
BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Delete"
Object.ToolTipText = "1041"
Object.Tag = ""
ImageIndex = 6
EndProperty
BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "Properties"
Object.ToolTipText = "1042"
Object.Tag = ""
ImageIndex = 7
EndProperty
BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "ViewLarge"
Object.ToolTipText = "1043"
Object.Tag = ""
ImageIndex = 8
Style = 2
EndProperty
BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "ViewSmall"
Object.ToolTipText = "1044"
Object.Tag = ""
ImageIndex = 9
Style = 2
EndProperty
BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "ViewList"
Object.ToolTipText = "1045"
Object.Tag = ""
ImageIndex = 10
Style = 2
EndProperty
BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = "ViewDetails"
Object.ToolTipText = "1046"
Object.Tag = ""
ImageIndex = 11
Style = 2
EndProperty
EndProperty
End
Begin VB.ListBox ItemList
Height = 4935
ItemData = "frmMain.frx":0000
Left = 4440
List = "frmMain.frx":0007
Sorted = -1 'True
TabIndex = 7
Top = 720
Width = 4215
End
Begin VB.PictureBox picSplitter
BackColor = &H00808080&
BorderStyle = 0 'None
FillColor = &H00808080&
Height = 4800
Left = 5400
ScaleHeight = 2090.126
ScaleMode = 0 'User
ScaleWidth = 780
TabIndex = 6
Top = 705
Visible = 0 'False
Width = 72
End
Begin VB.PictureBox picTitles
Align = 1 'Align Top
Appearance = 0 'Flat
BorderStyle = 0 'None
ForeColor = &H80000008&
Height = 300
Left = 0
ScaleHeight = 300
ScaleWidth = 8745
TabIndex = 2
TabStop = 0 'False
Top = 420
Width = 8745
Begin VB.Label lblTitle
BorderStyle = 1 'Fixed Single
Caption = " ListView:"
Height = 270
Index = 1
Left = 2078
TabIndex = 4
Tag = "1048"
Top = 12
Width = 3216
End
Begin VB.Label lblTitle
BorderStyle = 1 'Fixed Single
Caption = " TreeView:"
Height = 270
Index = 0
Left = 0
TabIndex = 3
Tag = "1047"
Top = 12
Width = 2016
End
End
Begin MSComDlg.CommonDialog dlgCommonDialog
Left = 2280
Top = 2160
_ExtentX = 847
_ExtentY = 847
_Version = 327680
FontSize = 1.73999e-39
End
Begin ComctlLib.StatusBar sbStatusBar
Align = 2 'Align Bottom
Height = 270
Left = 0
TabIndex = 0
Top = 5790
Width = 8745
_ExtentX = 15425
_ExtentY = 476
SimpleText = ""
_Version = 327680
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 9790
Text = "Status"
TextSave = "Status"
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
TextSave = "2/25/97"
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
TextSave = "5:19 PM"
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin ComctlLib.TreeView tvTreeView
Height = 4800
Left = 0
TabIndex = 5
Top = 705
Width = 4290
_ExtentX = 7567
_ExtentY = 8467
_Version = 327680
Indentation = 353
LabelEdit = 1
PathSeparator = "/"
Sorted = -1 'True
Style = 6
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Image imgSplitter
Height = 4785
Left = 4320
MousePointer = 9 'Size W E
Top = 720
Width = 150
End
Begin ComctlLib.ImageList imlIcons
Left = 1740
Top = 1350
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 327680
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 11
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":0015
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":01B7
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":0359
Key = ""
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":04FB
Key = ""
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":069D
Key = ""
EndProperty
BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":083F
Key = ""
EndProperty
BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":09E1
Key = ""
EndProperty
BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":0B83
Key = ""
EndProperty
BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":0D25
Key = ""
EndProperty
BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":0EC7
Key = ""
EndProperty
BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "frmMain.frx":1069
Key = ""
EndProperty
EndProperty
End
Begin VB.Menu mnuFile
Caption = "1000"
Begin VB.Menu mnuFileOpen
Caption = "1001"
End
Begin VB.Menu mnuFileFind
Caption = "1002"
End
Begin VB.Menu mnuFileBar1
Caption = "-"
End
Begin VB.Menu mnuFileSendTo
Caption = "1003"
End
Begin VB.Menu mnuFileBar2
Caption = "-"
End
Begin VB.Menu mnuFileNew
Caption = "1004"
End
Begin VB.Menu mnuFileBar3
Caption = "-"
End
Begin VB.Menu mnuFileDelete
Caption = "1005"
End
Begin VB.Menu mnuFileRename
Caption = "1006"
End
Begin VB.Menu mnuFileProperties
Caption = "1007"
End
Begin VB.Menu mnuFileBar4
Caption = "-"
End
Begin VB.Menu mnuFileMRU
Caption = ""
Index = 0
Visible = 0 'False
End
Begin VB.Menu mnuFileMRU
Caption = ""
Index = 1
Visible = 0 'False
End
Begin VB.Menu mnuFileMRU
Caption = ""
Index = 2
Visible = 0 'False
End
Begin VB.Menu mnuFileMRU
Caption = ""
Index = 3
Visible = 0 'False
End
Begin VB.Menu mnuFileBar5
Caption = "-"
Visible = 0 'False
End
Begin VB.Menu mnuFileClose
Caption = "1008"
End
End
Begin VB.Menu mnuEdit
Caption = "1009"
Begin VB.Menu mnuEditUndo
Caption = "1010"
Shortcut = ^Z
End
Begin VB.Menu mnuEditBar1
Caption = "-"
End
Begin VB.Menu mnuEditCut
Caption = "1011"
Shortcut = ^X
End
Begin VB.Menu mnuEditCopy
Caption = "1012"
Shortcut = ^C
End
Begin VB.Menu mnuEditPaste
Caption = "1013"
Shortcut = ^V
End
Begin VB.Menu mnuEditPasteSpecial
Caption = "1014"
End
Begin VB.Menu mnuEditBar2
Caption = "-"
End
Begin VB.Menu mnuEditDSelectAll
Caption = "1015"
Shortcut = ^A
End
Begin VB.Menu mnuEditInvertSelection
Caption = "1016"
End
End
Begin VB.Menu mnuView
Caption = "1017"
Begin VB.Menu mnuViewToolbar
Caption = "1018"
Checked = -1 'True
End
Begin VB.Menu mnuViewStatusBar
Caption = "1019"
Checked = -1 'True
End
Begin VB.Menu mnuViewBar2
Caption = "-"
End
Begin VB.Menu mnuListViewMode
Caption = "1020"
Index = 0
End
Begin VB.Menu mnuListViewMode
Caption = "1021"
Index = 1
End
Begin VB.Menu mnuListViewMode
Caption = "1022"
Index = 2
End
Begin VB.Menu mnuListViewMode
Caption = "1023"
Index = 3
End
Begin VB.Menu mnuViewBar3
Caption = "-"
End
Begin VB.Menu mnuViewArrangeIcons
Caption = "1024"
Begin VB.Menu mnuVAIByDate
Caption = "1025"
End
Begin VB.Menu mnuVAIByName
Caption = "1026"
End
Begin VB.Menu mnuVAIByType
Caption = "1027"
End
Begin VB.Menu mnuVAIBySize
Caption = "1028"
End
End
Begin VB.Menu mnuViewLineUpIcons
Caption = "1029"
End
Begin VB.Menu mnuViewBar4
Caption = "-"
End
Begin VB.Menu mnuViewRefresh
Caption = "1030"
End
Begin VB.Menu mnuViewOptions
Caption = "1031"
End
End
Begin VB.Menu mnuHelp
Caption = "1032"
Begin VB.Menu mnuHelpContents
Caption = "1033"
End
Begin VB.Menu mnuHelpSearch
Caption = "1034"
End
Begin VB.Menu mnuHelpBar1
Caption = "-"
End
Begin VB.Menu mnuHelpAbout
Caption = "1035"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const NAME_COLUMN = 0
Const TYPE_COLUMN = 1
Const SIZE_COLUMN = 2
Const DATE_COLUMN = 3
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Dim mbMoving As Boolean
Const sglSplitLimit = 500
Private Sub Form_Load()
LoadResStrings Me
Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
' Set Treeview control properties.
tvTreeView.LineStyle = tvwRootLines ' Linestyle 1
Dim Nodx As Node
Set Nodx = tvTreeView.Nodes.Add(, , "/", "/")
' Add Node objects.
PopulateTree tvTreeView, "/"
Nodx.Expanded = True
End Sub
Private Sub Form_Paint()
'ItemList.View = Val(GetSetting(App.Title, "Settings", "ViewMode", "0"))
'tbToolBar.Buttons(ItemList.View + LISTVIEW_BUTTON).Value = tbrPressed
'mnuListViewMode(ItemList.View).Checked = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
'close all sub forms
For i = Forms.Count - 1 To 1 Step -1
Unload Forms(i)
Next
If Me.WindowState <> vbMinimized Then
SaveSetting App.Title, "Settings", "MainLeft", Me.Left
SaveSetting App.Title, "Settings", "MainTop", Me.Top
SaveSetting App.Title, "Settings", "MainWidth", Me.Width
SaveSetting App.Title, "Settings", "MainHeight", Me.Height
End If
'SaveSetting App.Title, "Settings", "ViewMode", ItemList.View
End Sub
Private Sub ItemList_ShowNode(Nodx As Node)
Dim mb As IMSMetaBase
Set mb = CreateObject("IISAdmin.Object")
Dim i As Long
Dim bytePath() As Byte
Dim Path As String
Dim EnumDataObj As IMSMetaDataItem
Dim strItem As String
On Error Resume Next
' Clear the current contents
ItemList.Clear
' Open the selected node
Path = Nodx.key
Err.Clear
bytePath = StrConv(Path & Chr(0), vbFromUnicode)
Set mk = mb.OpenKey(1, 100, bytePath)
If (Err.Number <> 0) Then
Debug.Print ("Open Meta Object Error Code = " & Hex(Err.Number))
Err.Clear
Exit Sub
End If
Set EnumDataObj = mk.DataItem
' Enumerate the properties on this node
i = 0
Do
' Indicate we want all user types and datatypes
EnumDataObj.UserType = 0
EnumDataObj.DataType = 0
EnumDataObj.Attributes = 0
mk.EnumData EnumDataObj, i
If (Err.Number <> 0) Then
Debug.Print ("EnumData Error Code = " & Hex(Err.Number) & " (" & Err.Description & ")")
Err.Clear
GoTo CloseMb
End If
strItem = EnumDataObj.Identifier
' Add the user type
If (EnumDataObj.UserType = 1) Then
strItem = strItem & " IIS_MD_UT_SERVER "
ElseIf (EnumDataObj.UserType = 2) Then
strItem = strItem & " IIS_MD_UT_FILE "
Else
strItem = strItem & " MD_UT_UNKNOWN "
End If
' Do the appropriate datatype conversion
NewDataValue = EnumDataObj.DataType
If (NewDataValue = 1) Then
strItem = strItem & "MD_DWORD = " & EnumDataObj.Value
ElseIf (NewDataValue = 2) Then
Dim j As Long
j = 0
tmpStr = ""
Do While (EnumDataObj.Value(j) <> 0)
tmpStr = tmpStr & Chr(EnumDataObj.Value(j))
j = j + 1
Loop
strItem = strItem & "MD_STRING = " & tmpStr
End If
ItemList.AddItem strItem
If (Err.Number <> 0) Then
Debug.Print ("EnumData Error Code = " & Err.Number & " (" & Err.Description & ")")
Err.Clear
'Exit Sub
End If
i = i + 1
Loop While (True)
CloseMb:
mk.Close
End Sub
Private Sub ItemList_DblClick()
' Get the current selection and show it
Set DataForm = New frmMetaData
DataForm.SetData Me.tvTreeView.SelectedItem.key, ItemList.Text
DataForm.Show , Me
' Refresh the listbox
End Sub
Private Sub ItemList_KeyUp(KeyCode As Integer, Shift As Integer)
' Capture the delete key
If KeyCode = 46 Then
Dim mb As IMSMetaBase
Set mb = CreateObject("IISAdmin.Object")
Dim bytePath() As Byte
Dim ID As Long
Dim DataType As Long
Dim Path As String
Dim mk As IMSMetaKey
ID = Val(ItemList.Text)
strPath = tvTreeView.SelectedItem.key
' Choose the datatype we're deleting (why do we need to do this)?
If (InStr(1, ItemList.Text, "MD_DWORD", vbBinaryCompare) <> 0) Then
DataType = 1
ElseIf (InStr(1, ItemList.Text, "MD_STRING", vbBinaryCompare) <> 0) Then
DataType = 2
End If
' Open the selected node
Err.Clear
bytePath = StrConv(strPath & Chr(0), vbFromUnicode)
Set mk = mb.OpenKey(3, 100, bytePath)
If (Err.Number <> 0) Then
Debug.Print ("Open Key Error Code = " & Err.Number)
Err.Clear
Exit Sub
End If
mk.DeleteData ID, DataType
If (Err.Number <> 0) Then
MsgBox "DeleteData Error Code = " & Err.Number & " (" & Err.Description & ")"
Err.Clear
GoTo CloseMb
End If
CloseMb:
mk.Close
End If
End Sub
Private Sub mnuHelpAbout_Click()
frmAbout.Show vbModal, Me
End Sub
Private Sub mnuViewOptions_Click()
'To Do
MsgBox "Options Dialog Code goes here!"
End Sub
Private Sub mnuViewStatusBar_Click()
If mnuViewStatusBar.Checked Then
sbStatusBar.Visible = False
mnuViewStatusBar.Checked = False
Else
sbStatusBar.Visible = True
mnuViewStatusBar.Checked = True
End If
SizeControls imgSplitter.Left
End Sub
Private Sub mnuViewToolbar_Click()
If mnuViewToolbar.Checked Then
tbToolBar.Visible = False
mnuViewToolbar.Checked = False
Else
tbToolBar.Visible = True
mnuViewToolbar.Checked = True
End If
SizeControls imgSplitter.Left
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.Width < 3000 Then Me.Width = 3000
SizeControls imgSplitter.Left
End Sub
Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With imgSplitter
picSplitter.Move .Left, .Top, .Width \ 2, .Height - 20
End With
picSplitter.Visible = True
mbMoving = True
End Sub
Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim sglPos As Single
If mbMoving Then
sglPos = X + imgSplitter.Left
If sglPos < sglSplitLimit Then
picSplitter.Left = sglSplitLimit
ElseIf sglPos > Me.Width - sglSplitLimit Then
picSplitter.Left = Me.Width - sglSplitLimit
Else
picSplitter.Left = sglPos
End If
End If
End Sub
Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
SizeControls picSplitter.Left
picSplitter.Visible = False
mbMoving = False
End Sub
Sub SizeControls(X As Single)
On Error Resume Next
'set the width
If X < 1500 Then X = 1500
If X > (Me.Width - 1500) Then X = Me.Width - 1500
tvTreeView.Width = X
imgSplitter.Left = X
ItemList.Left = X + 40
ItemList.Width = Me.Width - (tvTreeView.Width + 140)
lblTitle(0).Width = tvTreeView.Width
lblTitle(1).Left = ItemList.Left + 20
lblTitle(1).Width = ItemList.Width - 40
'set the top
If tbToolBar.Visible Then
tvTreeView.Top = tbToolBar.Height + picTitles.Height
Else
tvTreeView.Top = picTitles.Height
End If
ItemList.Top = tvTreeView.Top
'set the height
If sbStatusBar.Visible Then
tvTreeView.Height = Me.ScaleHeight - (picTitles.Top + picTitles.Height + sbStatusBar.Height)
Else
tvTreeView.Height = Me.ScaleHeight - (picTitles.Top + picTitles.Height)
End If
ImageList.Height = tvTreeView.Height
imgSplitter.Top = tvTreeView.Top
imgSplitter.Height = tvTreeView.Height
End Sub
Private Sub TreeView1_DragDrop(Source As Control, X As Single, Y As Single)
If Source = imgSplitter Then
SizeControls X
End If
End Sub
Private Sub tbToolBar_ButtonClick(ByVal Button As ComctlLib.Button)
Select Case Button.key
Case "Back"
'To Do
MsgBox "Back Code goes here!"
Case "Forward"
'To Do
MsgBox "Forward Code goes here!"
Case "Cut"
mnuEditCut_Click
Case "Copy"
mnuEditCopy_Click
Case "Paste"
mnuEditPaste_Click
Case "Delete"
mnuFileDelete_Click
Case "Properties"
mnuFileProperties_Click
Case "ViewLarge"
mnuListViewMode_Click lvwIcon
Case "ViewSmall"
mnuListViewMode_Click lvwSmallIcon
Case "ViewList"
mnuListViewMode_Click lvwList
Case "ViewDetails"
mnuListViewMode_Click lvwReport
End Select
End Sub
Private Sub mnuHelpContents_Click()
Dim nRet As Integer
'if there is no helpfile for this project display a message to the user
'you can set the HelpFile for your application in the
'Project Properties dialog
If Len(App.HelpFile) = 0 Then
MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuHelpSearch_Click()
Dim nRet As Integer
'if there is no helpfile for this project display a message to the user
'you can set the HelpFile for your application in the
'Project Properties dialog
If Len(App.HelpFile) = 0 Then
MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
Else
On Error Resume Next
nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
If Err Then
MsgBox Err.Description
End If
End If
End Sub
Private Sub mnuVAIByDate_Click()
'To Do
' lvListView.SortKey = DATE_COLUMN
End Sub
Private Sub mnuVAIByName_Click()
'To Do
' lvListView.SortKey = NAME_COLUMN
End Sub
Private Sub mnuVAIBySize_Click()
'To Do
' lvListView.SortKey = SIZE_COLUMN
End Sub
Private Sub mnuVAIByType_Click()
'To Do
' lvListView.SortKey = TYPE_COLUMN
End Sub
Private Sub mnuListViewMode_Click(Index As Integer)
'uncheck the current type
mnuListViewMode(lvListView.View).Checked = False
'set the listview mode
lvListView.View = Index
'check the new type
mnuListViewMode(Index).Checked = True
'set the toolabr to the same new type
tbToolBar.Buttons(Index + LISTVIEW_BUTTON).Value = tbrPressed
End Sub
Private Sub mnuViewLineUpIcons_Click()
'To Do
lvListView.Arrange = lvwAutoLeft
End Sub
Private Sub mnuViewRefresh_Click()
'To Do
MsgBox "Refresh Code goes here!"
End Sub
Private Sub mnuEditCopy_Click()
'To Do
MsgBox "Copy Code goes here!"
End Sub
Private Sub mnuEditCut_Click()
'To Do
MsgBox "Cut Code goes here!"
End Sub
Private Sub mnuEditDSelectAll_Click()
'To Do
MsgBox "Select All Code goes here!"
End Sub
Private Sub mnuEditInvertSelection_Click()
'To Do
MsgBox "Invert Selection Code goes here!"
End Sub
Private Sub mnuEditPaste_Click()
'To Do
MsgBox "Paste Code goes here!"
End Sub
Private Sub mnuEditPasteSpecial_Click()
'To Do
MsgBox "Paste Special Code goes here!"
End Sub
Private Sub mnuEditUndo_Click()
'To Do
MsgBox "Undo Code goes here!"
End Sub
Private Sub mnuFileOpen_Click()
'To Do
MsgBox "Open Code goes here!"
End Sub
Private Sub mnuFileFind_Click()
'To Do
MsgBox "Find Code goes here!"
End Sub
Private Sub mnuFileSendTo_Click()
'To Do
MsgBox "Send To Code goes here!"
End Sub
Private Sub mnuFileNew_Click()
'To Do
MsgBox "New File Code goes here!"
End Sub
Private Sub mnuFileDelete_Click()
'To Do
MsgBox "Delete Code goes here!"
End Sub
Private Sub mnuFileRename_Click()
'To Do
MsgBox "Rename Code goes here!"
End Sub
Private Sub mnuFileProperties_Click()
'To Do
MsgBox "Properties Code goes here!"
End Sub
Private Sub mnuFileMRU_Click(Index As Integer)
'To Do
MsgBox "MRU Code goes here!"
End Sub
Private Sub mnuFileClose_Click()
'unload the form
Unload Me
End Sub
Private Sub tvTreeView_Click()
Dim Nodx As Node
Set Nodx = tvTreeView.SelectedItem()
ItemList_ShowNode Nodx
End Sub
Private Sub tvTreeView_KeyUp(KeyCode As Integer, Shift As Integer)
Dim Nodx As Node
Set Nodx = tvTreeView.SelectedItem()
ItemList_ShowNode Nodx
End Sub
|
Out "Starting..."
Set oLoc = CreateObject("WbemScripting.SWbemLocatorEx")
Out "Created LocatorEx"
Set oObj = oLoc.Open("umi://nw01t1/ldap/.DC=com/.DC=microsoft/.DC=nttest/.DC=nw01t1dom/.ou=VB_UMI_Test", "nw01t1domnb\administrator", "nw01t1domnb")
'Set oObj = oLoc.Open("umi://nw01t1/ldap", "nw01t1domnb\administrator", "nw01t1domnb")
Out "Bound to umi://nw01t1/ldap/.ou=VB_UMI_Test"
Out "Got Object " & oObj.Path_
sName = "organizationalUnit.ou=Test" & CLng((now()-Int(now()))*24*60*60)
Set oChild = oObj.CreateInstance_(sName)
oChild.Put_
Out "Created " & oChild.Path_
Out "Attempting Delete"
oObj.DeleteInstance_ sName
Out "Succeeded"
Sub Out(sLine)
WScript.Echo sLine
End Sub
|
'Solution derived from http://stackoverflow.com/questions/8002252/euler-project-18-approach.
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objinfile = objfso.OpenTextFile(objfso.GetParentFolderName(WScript.ScriptFullName) &_
"\triangle.txt",1,False)
row = Split(objinfile.ReadAll,vbCrLf)
For i = UBound(row) To 0 Step -1
row(i) = Split(row(i)," ")
If i < UBound(row) Then
For j = 0 To UBound(row(i))
If (row(i)(j) + row(i+1)(j)) > (row(i)(j) + row(i+1)(j+1)) Then
row(i)(j) = CInt(row(i)(j)) + CInt(row(i+1)(j))
Else
row(i)(j) = CInt(row(i)(j)) + CInt(row(i+1)(j+1))
End If
Next
End If
Next
WScript.Echo row(0)(0)
objinfile.Close
Set objfso = Nothing
|
'
' Copyright (c) Microsoft Corporation. All rights reserved.
'
' VBScript Source File
'
' Script Name: IIsCnfg.vbs
'
Option Explicit
On Error Resume Next
' Error codes
Const ERR_OK = 0
Const ERR_GENERAL_FAILURE = 1
'''''''''''''''''''''
' Messages
Const L_ConfImported_Text = "Configuration imported from %1 in file"
Const L_ConfImportedp2_Text = "%1 to %2 in the Metabase."
Const L_ConfExported_Text = "Configuration exported from %1 to file %2."
Const L_MDSaved_Text = "Metadata successfully flushed to disk."
Const L_Error_ErrorMessage = "Error &H%1: %2"
Const L_GetComputerObject_ErrorMessage = "Could not get computer object"
Const L_Import_ErrorMessage = "Error while importing configuration."
Const L_Export_ErrorMessage = "Error while exporting configuration."
Const L_SaveData_ErrorMessage = "Error while flushing metabase."
Const L_OnlyOneOper_ErrorMessage = "Please specify only one operation at a time."
Const L_ScriptHelper_ErrorMessage = "Could not create an instance of the"
Const L_ScriptHelperp2_ErrorMessage = "IIsScriptHelper object."
Const L_ChkScpHelperReg_ErrorMessage = "Please register the Microsoft.IIsScriptHelper"
Const L_ChkScpHelperRegp2_ErrorMessage = "component."
Const L_CmdLib_ErrorMessage = "Could not create an instance of the CmdLib object."
Const L_ChkCmdLibReg_ErrorMessage = "Please register the Microsoft.CmdLib component."
Const L_WMIConnect_ErrorMessage = "Could not connect to WMI provider."
Const L_RequiredArgsMissing_ErrorMessage = "Required arguments are missing."
Const L_FileExpected_ErrorMessage = "Argument is a folder path while expecting a file"
Const L_FileExpectedp2_ErrorMessage = "path."
Const L_ParentFolderDoesntExist_ErrorMessage = "Parent folder doesn't exist."
Const L_FileDoesntExist_ErrorMessage = "Input file doesn't exist."
Const L_FileAlreadyExist_ErrorMessage = "Export file specified already exists."
Const L_NotEnoughParams_ErrorMessage = "Not enough parameters."
Const L_InvalidSwitch_ErrorMessage = "Invalid switch: %1"
Const L_IncorrectPassword_ErrorMessage = "The password specified is incorrect."
Const L_InvalidXML_ErrorMessage = "The import file appears to contain invalid XML."
Const L_Admin_ErrorMessage = "You cannot run this command because you are not an"
Const L_Adminp2_ErrorMessage = "administrator on the server you are trying to configure."
Const L_DriveLetter_Message = "Mapping local drive %1 to admin share on server %2"
Const L_Shell_ErrorMessage = "Could not create an instance of the WScript.Shell"
Const L_Shellp2_ErrorMessage = "object."
Const L_FS_ErrorMessage = "Could not create an instance of the"
Const L_FSp2_ErrorMessage = "Scripting.FileSystemObject object."
Const L_Network_ErrorMessage = "Could not create an instance of the"
Const L_Networkp2_ErrorMessage = "WScript.Network object."
Const L_BackingUp_Message = "Backing up server %1"
Const L_Restoring_Message = "Restoring on server %1"
Const L_Backup_ErrorMessage = "Failure creating backup."
Const L_BackupComplete_Message = "Backup complete."
Const L_Restore_ErrorMessage = "Failure restoring backup."
Const L_RestoreComplete_Message = "Restore complete."
Const L_UnMap_Message = "Unmapping local drive %1"
Const L_NoDrive_ErrorMessage = "No drives available for mapping on local machine."
Const L_Copy_Message = "Copying backup files..."
Const L_Copy_ErrorMessage = "Error copying files."
Const L_ReturnVal_ErrorMessage = "Call returned with code %1"
Const L_CopyComplete_Message = "Copy operation complete."
'''''''''''''''''''''
' Help
Const L_Empty_Text = ""
' General help messages
Const L_SeeHelp_Message = "Type IIsCnfg /? for help."
Const L_SeeImportHelp_Message = "Type IIsCnfg /import /? for help."
Const L_SeeExportHelp_Message = "Type IIsCnfg /export /? for help."
Const L_Help_HELP_General01_Text = "Description: Import and export IIS configuration."
Const L_Help_HELP_General02_Text = "Syntax: IIsCnfg [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_General03_Text = " /<operation> [arguments]"
Const L_Help_HELP_General04_Text = "Parameters:"
Const L_Help_HELP_General05_Text = ""
Const L_Help_HELP_General06_Text = "Value Description"
Const L_Help_HELP_General07_Text = "/s <server> Connect to machine <server>."
Const L_Help_HELP_General07p2_Text = " [Default: this system]"
Const L_Help_HELP_General08_Text = "/u <username> Connect as <domain>\<username> or"
Const L_Help_HELP_General09_Text = " <username>. [Default: current user]"
Const L_Help_HELP_General10_Text = "/p <password> Password for the <username> user."
Const L_Help_HELP_General11_Text = "<operation> /import Import configuration from"
Const L_Help_HELP_General11p1_Text = " a configuration file."
Const L_Help_HELP_General12_Text = " /export Export configuration into"
Const L_Help_HELP_General12p1_Text = " a configuration file."
Const L_Help_HELP_General13_Text = " /copy Copy configuration from"
Const L_Help_HELP_General14_Text = " one machine to another."
Const L_Help_HELP_General22_Text = "For detailed usage:"
Const L_Help_HELP_General23_Text = "IIsCnfg /import /?"
Const L_Help_HELP_General24_Text = "IIsCnfg /export /?"
Const L_Help_HELP_General25_Text = "IIsCnfg /copy /?"
Const L_Help_HELP_General26_Text = "IIsCnfg /save /?"
' Common help messages
Const L_Help_HELP_Common13_Text = "/d <DecryptPass> Specifies the password used to"
Const L_Help_HELP_Common13p1_Text = " decrypt encrypted configuration data."
Const L_Help_HELP_Common13p2_Text = " [Default: """"]"
Const L_Help_HELP_Common14_Text = "/f <File> Configuration file."
Const L_Help_HELP_Common15_Text = "/sp <SourcePath> The full metabase path to start"
Const L_Help_HELP_Common15p1_Text = " reading from the configuration file."
Const L_Help_HELP_Common21_Text = "Examples:"
' Copy help messages
Const L_Help_HELP_Copy1_Text = "Description: Copy configuration from a source server to a"
Const L_Help_HELP_Copy1p2_Text = " target server."
Const L_Help_HELP_Copy2_Text = "Syntax: iiscnfg [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Copy2p2_Text = " /copy /ts <target server> /tu <target user>"
Const L_Help_HELP_Copy2p3_Text = " /tp <target password>"
Const L_Help_HELP_Copy3_Text = "Parameters:"
Const L_Help_HELP_Copy4_Text = "Value Description"
Const L_Help_HELP_Copy5_Text = "/s <server> Connect to machine <server>"
Const L_Help_HELP_Copy5p2_Text = " [Default: this system]"
Const L_Help_HELP_Copy6_Text = "/u <username> Connect as <domain>/<username>"
Const L_Help_HELP_Copy7_Text = " or <username> [Default: current user]"
Const L_Help_HELP_Copy8_Text = "/p <password> Password for the <username> user"
Const L_Help_HELP_Copy9_Text = "/ts Target server to copy configuration to"
Const L_Help_HELP_Copy10_Text = "/tu Username to use when connecting to the"
Const L_Help_HELP_Copy10p2_Text = " target server"
Const L_Help_HELP_Copy11_Text = "/tp Password to use when connecting to the"
Const L_Help_HELP_Copy11p2_Text = " target server"
Const L_Help_HELP_Copy12_Text = "Examples:"
Const L_Help_HELP_Copy13_Text = "iiscnfg.vbs /copy /ts TargetServer /tu Administrator /tp Pk$^("
Const L_Help_HELP_Copy14_Text = "iiscnfg.vbs /s SourceServer /u Administrator /p Kj30W /copy"
Const L_Help_HELP_Copy14p2_Text = " /ts TargetServer /tu Administrator /tp Pk$^j"
' Import help messages
Const L_Help_HELP_Import01_Text = "Description: Import configuration from a configuration file."
Const L_Help_HELP_Import02_Text = "Syntax: IIsCnfg [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Import02p1_Text = " /import [/d <DeCryptPass>] /f <File> /sp <SourcePath>"
Const L_Help_HELP_Import02p2_Text = " /dp <DestPath> [/inherited] [/children] [/merge]"
Const L_Help_HELP_Import16_Text = "/dp <DestPath> The metabase path destination for"
Const L_Help_HELP_Import16p1_Text = " imported properties. If the keytype"
Const L_Help_HELP_Import16p2_Text = " of the SourcePath and the DestPath do"
Const L_Help_HELP_Import16p3_Text = " not match, an error occurs."
Const L_Help_HELP_Import17_Text = "/inherited Import inherited settings if set."
Const L_Help_HELP_Import18_Text = "/children Import configuration for child nodes."
Const L_Help_HELP_Import19_Text = "/merge Merge imported configuration with"
Const L_Help_HELP_Import19p1_Text = " existing configuration."
Const L_Help_HELP_Import22_Text = "IIsCnfg /import /f c:\config.xml /sp /lm/w3svc/5/Root/401Kapp"
Const L_Help_HELP_Import22p1_Text = " /dp /lm/w3svc/1/Root/401Kapp"
' Export help messages
Const L_Help_HELP_Export01_Text = "Description: Export configuration into a configuration file."
Const L_Help_HELP_Export02_Text = "Syntax: IIsCnfg [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Export02p1_Text = " /export [/d <DeCryptPass>] /f <File> /sp <SourcePath>"
Const L_Help_HELP_Export02p2_Text = " [/inherited] [/children]"
Const L_Help_HELP_Export17_Text = "/inherited Export inherited settings if set."
Const L_Help_HELP_Export18_Text = "/children Export configuration for child nodes."
Const L_Help_HELP_Export22_Text = "IIsCnfg /export /f c:\config.xml /sp /lm/w3svc/5/Root/401Kapp"
' Save help messages
Const L_Help_HELP_Save01_Text = "Description: Save configuration to disk."
Const L_Help_HELP_Save02_Text = "Syntax: iiscnfg [/s <server> [/u <username> [/p <password>]]]"
Const L_Help_HELP_Save02p2_Text = " /save"
Const L_Help_HELP_Save22_Text = "iiscnfg.vbs /save"
Const L_Help_HELP_Save23_Text = "iiscnfg.vbs /s SourceServer /u Administrator /p Kj30W /save"
''''''''''''''''''''''''
' Operation codes
Const OPER_IMPORT = 1
Const OPER_EXPORT = 2
Const OPER_COPY = 3
Const OPER_SAVE = 4
' Import/Export flags
Const IMPORT_EXPORT_INHERITED = 1
Const IMPORT_EXPORT_NODE_ONLY = 2
Const IMPORT_EXPORT_MERGE = 4
'
' Main block
'
Dim oScriptHelper, oCmdLib
Dim strServer, strUser, strPassword, strSite
Dim strTarServer, strTarUser, strTarPassword
Dim strFile, strDecPass, strSourcePath, strDestPath
Dim intOperation, intResult, intFlags
Dim aArgs, arg
Dim strCmdLineOptions
Dim oError
' Default values
strServer = "."
strUser = ""
strPassword = ""
strTarServer = ""
strTarUser = ""
strTarPassword = ""
intOperation = 0
strFile = ""
strDecPass = ""
strSourcePath = ""
strDestPath = ""
intFlags = IMPORT_EXPORT_NODE_ONLY
' Instantiate the CmdLib for output string formatting
Set oCmdLib = CreateObject("Microsoft.CmdLib")
If Err.Number <> 0 Then
WScript.Echo L_CmdLib_ErrorMessage
WScript.Echo L_ChkCmdLibReg_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oCmdLib.ScriptingHost = WScript.Application
' Instantiate script helper object
Set oScriptHelper = CreateObject("Microsoft.IIsScriptHelper")
If Err.Number <> 0 Then
WScript.Echo L_ScriptHelper_ErrorMessage
WScript.Echo L_ScriptHelperp2_ErrorMessage
WScript.Echo L_ChkScpHelperReg_ErrorMessage
WScript.Echo L_ChkScpHelperRegp2_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oScriptHelper.ScriptHost = WScript
' Check if we are being run with cscript.exe instead of wscript.exe
oScriptHelper.CheckScriptEngine
' Minimum number of parameters must exist
If WScript.Arguments.Count < 1 Then
WScript.Echo L_RequiredArgsMissing_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
strCmdLineOptions = "[server:s:1;user:u:1;password:p:1];decpass:d:1;file:f:1;sourcepath:sp:1;" & _
"inherited:i:0;children:c:0;[import::0;destpath:dp:1;merge:m:0];save::0;" & _
"export::0;[copy::0;targetserver:ts:1;targetuser:tu:1;targetpassword:tp:1]"
Set oError = oScriptHelper.ParseCmdLineOptions(strCmdLineOptions)
If Not oError Is Nothing Then
If oError.ErrorCode = oScriptHelper.ERROR_NOT_ENOUGH_ARGS Then
' Not enough arguments for a specified switch
WScript.Echo L_NotEnoughParams_ErrorMessage
WScript.Echo L_SeeHelp_Message
Else
' Invalid switch
oCmdLib.vbPrintf L_InvalidSwitch_ErrorMessage, Array(oError.SwitchName)
WScript.Echo L_SeeHelp_Message
End If
WScript.Quit(ERR_GENERAL_FAILURE)
End If
If oScriptHelper.GlobalHelpRequested Then
DisplayHelpMessage
WScript.Quit(ERR_OK)
End If
For Each arg In oScriptHelper.Switches
Select Case arg
Case "server"
' Server information
strServer = oScriptHelper.GetSwitch(arg)
Case "user"
' User information
strUser = oScriptHelper.GetSwitch(arg)
Case "password"
' Password information
strPassword = oScriptHelper.GetSwitch(arg)
Case "targetserver"
' Server information
strTarServer = oScriptHelper.GetSwitch(arg)
Case "targetuser"
' User information
strTarUser = oScriptHelper.GetSwitch(arg)
Case "targetpassword"
' Password information
strTarPassword = oScriptHelper.GetSwitch(arg)
Case "import"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_IMPORT
If oScriptHelper.IsHelpRequested(arg) Then
DisplayImportHelpMessage
WScript.Quit(ERR_OK)
End If
Case "export"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_EXPORT
If oScriptHelper.IsHelpRequested(arg) Then
DisplayExportHelpMessage
WScript.Quit(ERR_OK)
End If
Case "copy"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_COPY
If oScriptHelper.IsHelpRequested(arg) Then
DisplayCopyHelpMessage
WScript.Quit(ERR_OK)
End If
Case "save"
If (intOperation <> 0) Then
WScript.Echo L_OnlyOneOper_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
intOperation = OPER_SAVE
If oScriptHelper.IsHelpRequested(arg) Then
DisplaySaveHelpMessage
WScript.Quit(ERR_OK)
End If
Case "file"
strFile = oScriptHelper.GetSwitch(arg)
Case "decpass"
strDecPass = oScriptHelper.GetSwitch(arg)
Case "sourcepath"
strSourcePath = oScriptHelper.GetSwitch(arg)
Case "destpath"
strDestPath = oScriptHelper.GetSwitch(arg)
Case "inherited"
intFlags = intFlags Or IMPORT_EXPORT_INHERITED
Case "children"
intFlags = intFlags And Not IMPORT_EXPORT_NODE_ONLY
Case "merge"
intFlags = intFlags Or IMPORT_EXPORT_MERGE
End Select
Next
' Check Parameters
If intOperation = 0 Then
WScript.Echo L_OperationRequired_ErrorMessage
WScript.Echo L_SeeHelp_Message
WScript.Quit(ERR_GENERAL_FAILURE)
End If
If intOperation = OPER_SAVE Then
ElseIf intOperation = OPER_COPY Then
If strTarServer = "" Or strTarUser = "" Or strTarPassword = "" Then
WScript.Echo L_RequiredArgsMissing_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Else
If strFile = "" Or strSourcePath = "" Or (intOperation = OPER_IMPORT And strDestPath = "") Then
WScript.Echo L_RequiredArgsMissing_ErrorMessage
If intOperation = OPER_IMPORT Then
WScript.Echo L_SeeImportHelp_Message
Else
WScript.Echo L_SeeExportHelp_Message
End If
WScript.Quit(ERR_GENERAL_FAILURE)
End If
End If
' Check if /p is specified but /u isn't. In this case, we should bail out with an error
If oScriptHelper.Switches.Exists("password") And Not oScriptHelper.Switches.Exists("user") Then
WScript.Echo L_PassWithoutUser_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
' Check if /u is specified but /p isn't. In this case, we should ask for a password
If oScriptHelper.Switches.Exists("user") And Not oScriptHelper.Switches.Exists("password") Then
strPassword = oCmdLib.GetPassword
End If
' Initializes authentication with remote machine
intResult = oScriptHelper.InitAuthentication(strServer, strUser, strPassword)
If intResult <> 0 Then
WScript.Quit(intResult)
End If
' Choose operation
Select Case intOperation
Case OPER_IMPORT
intResult = Import(strDecPass, strFile, strSourcePath, strDestPath, intFlags)
Case OPER_EXPORT
intResult = Export(strDecPass, strFile, strSourcePath, intFlags)
Case OPER_COPY
intResult = Repl(strServer, strUser, strPassword, strTarServer, strTarUser, strTarPassword)
Case OPER_SAVE
intResult = SaveMD()
End Select
' Return value to command processor
WScript.Quit(intResult)
'''''''''''''''''''''''''
' End Of Main Block
'''''''''''''''''''''
'''''''''''''''''''''''''''
' DisplayHelpMessage
'''''''''''''''''''''''''''
Sub DisplayHelpMessage()
WScript.Echo L_Help_HELP_General01_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General02_Text
WScript.Echo L_Help_HELP_General03_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General04_Text
WScript.Echo L_Help_HELP_General05_Text
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07p2_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_General11_Text
WScript.Echo L_Help_HELP_General11p1_Text
WScript.Echo L_Help_HELP_General12_Text
WScript.Echo L_Help_HELP_General12p1_Text
WScript.Echo L_Help_HELP_General13_Text
WScript.Echo L_Help_HELP_General14_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General22_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General23_Text
WScript.Echo L_Help_HELP_General24_Text
WScript.Echo L_Help_HELP_General25_Text
WScript.Echo L_Help_HELP_General26_Text
End Sub
Sub DisplayImportHelpMessage()
WScript.Echo L_Help_HELP_Import01_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Import02_Text
WScript.Echo L_Help_HELP_Import02p1_Text
WScript.Echo L_Help_HELP_Import02p2_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07p2_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_Common13_Text
WScript.Echo L_Help_HELP_Common13p1_Text
WScript.Echo L_Help_HELP_Common13p2_Text
WScript.Echo L_Help_HELP_Common14_Text
WScript.Echo L_Help_HELP_Common15_Text
WScript.Echo L_Help_HELP_Common15p1_Text
WScript.Echo L_Help_HELP_Import16_Text
WScript.Echo L_Help_HELP_Import16p1_Text
WScript.Echo L_Help_HELP_Import16p2_Text
WScript.Echo L_Help_HELP_Import16p3_Text
WScript.Echo L_Help_HELP_Import17_Text
WScript.Echo L_Help_HELP_Import18_Text
WScript.Echo L_Help_HELP_Import19_Text
WScript.Echo L_Help_HELP_Import19p1_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Common21_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Import22_Text
WScript.Echo L_Help_HELP_Import22p1_Text
End Sub
Sub DisplayCopyHelpMessage()
WScript.Echo L_Help_HELP_Copy1_Text
WScript.Echo L_Help_HELP_Copy1p2_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Copy2_Text
WScript.Echo L_Help_HELP_Copy2p2_Text
WScript.Echo L_Help_HELP_Copy2p3_Text
WScript.Echo L_Help_HELP_Copy3_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Copy4_Text
WScript.Echo L_Help_HELP_Copy5_Text
WScript.Echo L_Help_HELP_Copy5p2_Text
WScript.Echo L_Help_HELP_Copy6_Text
WScript.Echo L_Help_HELP_Copy7_Text
WScript.Echo L_Help_HELP_Copy8_Text
WScript.Echo L_Help_HELP_Copy9_Text
WScript.Echo L_Help_HELP_Copy10_Text
WScript.Echo L_Help_HELP_Copy10p2_Text
WScript.Echo L_Help_HELP_Copy11_Text
WScript.Echo L_Help_HELP_Copy11p2_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Copy12_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Copy13_Text
WScript.Echo L_Help_HELP_Copy14_Text
WScript.Echo L_Help_HELP_Copy14p2_Text
End Sub
Sub DisplayExportHelpMessage()
WScript.Echo L_Help_HELP_Export01_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Export02_Text
WScript.Echo L_Help_HELP_Export02p1_Text
WScript.Echo L_Help_HELP_Export02p2_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07p2_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Help_HELP_Common13_Text
WScript.Echo L_Help_HELP_Common13p1_Text
WScript.Echo L_Help_HELP_Common13p2_Text
WScript.Echo L_Help_HELP_Common14_Text
WScript.Echo L_Help_HELP_Common15_Text
WScript.Echo L_Help_HELP_Common15p1_Text
WScript.Echo L_Help_HELP_Export17_Text
WScript.Echo L_Help_HELP_Export18_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Common21_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Export22_Text
End Sub
Sub DisplaySaveHelpMessage()
WScript.Echo L_Help_HELP_Save01_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Save02_Text
WScript.Echo L_Help_HELP_Save02p2_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_General06_Text
WScript.Echo L_Help_HELP_General07_Text
WScript.Echo L_Help_HELP_General07p2_Text
WScript.Echo L_Help_HELP_General08_Text
WScript.Echo L_Help_HELP_General09_Text
WScript.Echo L_Help_HELP_General10_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Common21_Text
WScript.Echo L_Empty_Text
WScript.Echo L_Help_HELP_Save22_Text
WScript.Echo L_Help_HELP_Save23_Text
End Sub
'''''''''''''''''''''''''''
' Copy Function
'''''''''''''''''''''''''''
Function Repl(strSourceServer, strSourceUser, strSourcePwd, strDestServer, strDestUser, strDestPwd)
If (strSourceServer = ".") Then
strSourceServer = ""
End If
' Do the first backup
Dim strBackupCommand
Dim strSourceDrive, strDrvLetter, strSourcePath
Dim oShell, oFS, oNetwork
Dim strDestDrive, strDestPath
Dim strCopyCommand, strDelCommand, strRestoreCommand
Set oShell = WScript.CreateObject("WScript.Shell")
If Err.Number <> 0 Then
WScript.Echo L_Shell_ErrorMessage
WScript.Echo L_Shellp2_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
If Err.Number <> 0 Then
WScript.Echo L_FS_ErrorMessage
WScript.Echo L_FSp2_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
Set oNetwork = WScript.CreateObject("WScript.Network")
If Err.Number <> 0 Then
WScript.Echo L_Network_ErrorMessage
WScript.Echo L_Networkp2_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
strBackupCommand = "cmd /c %SystemRoot%\system32\cscript.exe %SystemRoot%\system32\iisback.vbs /backup"
If strSourceServer <> "" Then
strBackupCommand = strBackupCommand & " /s " & strSourceServer
Else
strSourceServer = "127.0.0.1"
End If
If strSourceUser <> "" Then
strBackupCommand = strBackupCommand & " /u " & strSourceUser
End If
If strSourcePwd <> "" Then
strBackupCommand = strBackupCommand & " /p " & strSourcePwd
End If
' need overwrite in case a previous attempt failed
strBackupCommand = strBackupCommand & " /b iisreplback /overwrite"
' backup the source server
oCmdLib.vbPrintf L_BackingUp_Message, Array(strSourceServer)
intResult = oShell.Run(strBackupCommand, 1, TRUE)
WScript.Echo L_BackupComplete_Message
' Now map drive to source server
' Find a drive letter
strSourceDrive = "NO DRIVE"
For strDrvLetter = Asc("C") to Asc("Z")
If Not oFS.DriveExists(Chr(strDrvLetter)) Then
strSourceDrive = Chr(strDrvLetter)
Exit For
End If
Next
If strSourceDrive = "NO DRIVE" Then
' No drive letter available
WScript.Echo L_NoDrive_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
strSourceDrive = strSourceDrive & ":"
strSourcePath = "\\" & strSourceServer & "\ADMIN$"
' Map the drive
oCmdLib.vbPrintf L_DriveLetter_Message, Array(strSourceDrive, strSourceServer)
If strSourceUser <> "" Then
oNetwork.MapNetworkDrive strSourceDrive, strSourcePath, FALSE, strSourceUser, strSourcePwd
Else
oNetwork.MapNetworkDrive strSourceDrive, strSourcePath
End If
' Now map drive to destination server
' Find a drive letter
strDestDrive = "NO DRIVE"
For strDrvLetter = Asc("C") to Asc("Z")
If Not oFS.DriveExists(Chr(strDrvLetter)) Then
strDestDrive = Chr(strDrvLetter)
Exit For
End If
Next
If strDestDrive = "NO DRIVE" Then
' No drive letter available
WScript.Echo L_NoDrive_ErrorMessage
WScript.Quit(ERR_GENERAL_FAILURE)
End If
strDestDrive = strDestDrive & ":"
strDestPath = "\\" & strDestServer & "\ADMIN$"
' Map the drive
oCmdLib.vbPrintf L_DriveLetter_Message, Array(strDestDrive, strDestServer)
If strDestUser <> "" Then
oNetwork.MapNetworkDrive strDestDrive, strDestPath, FALSE, strDestUser, strDestPwd
Else
oNetwork.MapNetworkDrive strDestDrive, strDestPath
End If
strCopyCommand = "cmd /c copy /Y " & strSourceDrive & "\system32\inetsrv\metaback\iisreplback.* "
strCopyCommand = strCopyCommand & strDestDrive & "\system32\inetsrv\metaback"
' Copy the files
WScript.Echo L_Copy_Message
WScript.Echo strCopyCommand
intResult = oShell.Run(strCopyCommand, 1, TRUE)
If intResult <> 0 Then
oCmdLib.vbPrintf L_ReturnVal_ErrorMessage, Array(intResult)
WScript.Echo L_Copy_ErrorMessage
WScript.Quit(intResult)
End If
strDelCommand = "cmd /c del /f /q " & strSourceDrive & "\system32\inetsrv\metaback\iisreplback.*"
intResult = oShell.Run(strDelCommand, 1, TRUE)
' Unmap drive to source server
oCmdLib.vbPrintf L_UnMap_Message, Array(strSourceDrive)
oNetwork.RemoveNetworkDrive strSourceDrive
' Now do the restore on the destination server
strRestoreCommand = "cmd /c %SystemRoot%\system32\cscript.exe %SystemRoot%\system32\iisback.vbs /restore /s " & strDestServer
strRestoreCommand = strRestoreCommand & " /u " & strDestUser
strRestoreCommand = strRestoreCommand & " /p " & strDestPwd
strRestoreCommand = strRestoreCommand & " /b iisreplback"
oCmdLib.vbPrintf L_Restoring_Message, Array(strDestServer)
intResult = oShell.Run(strRestoreCommand, 1, TRUE)
If intResult <> 0 Then
oCmdLib.vbPrintf L_ReturnVal_ErrorMessage, Array(intResult)
WScript.Echo L_Restore_ErrorMessage
WScript.Quit(intResult)
End If
WScript.Echo L_RestoreComplete_Message
strDelCommand = "cmd /c del /f /q " & strDestDrive & "\system32\inetsrv\metaback\iisreplback.*"
intResult = oShell.Run(strDelCommand, 1, TRUE)
' Unmap drive to destination server
oCmdLib.vbPrintf L_UnMap_Message, Array(strDestDrive)
oNetwork.RemoveNetworkDrive strDestDrive
WScript.Echo L_CopyComplete_Message
End Function
'''''''''''''''''''''''''''
' Import Function
'''''''''''''''''''''''''''
Function Import(strDecPass, strFile, strSourcePath, strDestPath, intFlags)
Dim ComputerObj
Dim strFilePath
On Error Resume Next
' Normalize path first
strFilePath = oScriptHelper.NormalizeFilePath(strFile)
If Err Then
Select Case Err.Number
Case &H80070002
WScript.Echo L_FileExpected_ErrorMessage
WScript.Echo L_FileExpectedp2_ErrorMessage
Case &H80070003
WScript.Echo L_ParentFolderDoesntExist_ErrorMessage
End Select
Import = Err.Number
Exit Function
End If
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
Import = Err.Number
Exit Function
End If
Set ComputerObj = oScriptHelper.ProviderObj.get("IIsComputer='LM'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Adminp2_ErrorMessage
Case Else
WScript.Echo L_GetComputerObj_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
End Select
Import = Err.Number
Exit Function
End If
' Call Import method from the computer object
ComputerObj.Import strDecPass, strFilePath, strSourcePath, strDestPath, intFlags
If Err.Number Then
Select Case Err.Number
Case &H80070002
WScript.Echo L_FileDoesntExist_ErrorMessage
Case &H8007052B
WScript.Echo L_IncorrectPassword_ErrorMessage
Case &H800CC819
WScript.Echo L_InvalidXML_ErrorMessage
Case Else
WScript.Echo L_Import_ErrorMessage
WScript.Echo Err.Description
End Select
Import = Err.Number
Exit Function
End If
oCmdLib.vbPrintf L_ConfImported_Text, Array(strSourcePath)
oCmdLib.vbPrintf L_ConfImportedp2_Text, Array(strFile, strDestPath)
End Function
'''''''''''''''''''''''''''
' Export Function
'''''''''''''''''''''''''''
Function Export(strDecPass, strFile, strSourcePath, intFlags)
Dim ComputerObj
Dim strFilePath
On Error Resume Next
' Normalize path first
strFilePath = oScriptHelper.NormalizeFilePath(strFile)
If Err Then
Select Case Err.Number
Case &H80070002
WScript.Echo L_FileExpected_ErrorMessage
WScript.Echo L_FileExpectedp2_ErrorMessage
Case &H80070003
WScript.Echo L_ParentFolderDoesntExist_ErrorMessage
End Select
Export = Err.Number
Exit Function
End If
If oScriptHelper.FSObj.FileExists(strFilePath) Then
WScript.Echo L_FileAlreadyExist_ErrorMessage
Export = &H80070050
Exit Function
End If
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
Export = Err.Number
Exit Function
End If
Set ComputerObj = oScriptHelper.ProviderObj.get("IIsComputer='LM'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Adminp2_ErrorMessage
Case Else
WScript.Echo L_GetComputerObj_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
End Select
Export = Err.Number
Exit Function
End If
' Call Import method from the computer object
ComputerObj.Export strDecPass, strFilePath, strSourcePath, intFlags
If Err.Number Then
WScript.Echo L_Export_ErrorMessage
WScript.Echo Err.Description
Export = Err.Number
Exit Function
End If
oCmdLib.vbPrintf L_ConfExported_Text, Array(strSourcePath, strFile)
End Function
'''''''''''''''''''''''''''
' SaveMD Function
'''''''''''''''''''''''''''
Function SaveMD()
Dim ComputerObj
On Error Resume Next
oScriptHelper.WMIConnect
If Err.Number Then
WScript.Echo L_WMIConnect_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
SaveMD = Err.Number
Exit Function
End If
Set ComputerObj = oScriptHelper.ProviderObj.get("IIsComputer='LM'")
If Err.Number Then
Select Case Err.Number
Case &H80070005
WScript.Echo L_Admin_ErrorMessage
WScript.Echo L_Adminp2_ErrorMessage
Case Else
WScript.Echo L_GetComputerObj_ErrorMessage
oCmdLib.vbPrintf L_Error_ErrorMessage, Array(Hex(Err.Number), Err.Description)
End Select
SaveMD = Err.Number
Exit Function
End If
' Call Import method from the computer object
ComputerObj.SaveData
If Err.Number Then
WScript.Echo L_SaveData_ErrorMessage
WScript.Echo Err.Description
SaveMD = Err.Number
Exit Function
End If
WScript.Echo L_MDSaved_Text
End Function
|
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Object = "{FE0065C0-1B7B-11CF-9D53-00AA003C9CB6}#1.0#0"; "COMCT232.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmSpeakerPhone
BorderStyle = 0 'None
Caption = "Speaker Phone Specs"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 9480
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 5730
ScaleWidth = 9480
ShowInTaskbar = 0 'False
Visible = 0 'False
Begin TabDlg.SSTab SSTab1
Height = 5055
Left = 0
TabIndex = 1
TabStop = 0 'False
Top = 360
Width = 9405
_ExtentX = 16589
_ExtentY = 8916
_Version = 327681
Tabs = 1
TabsPerRow = 8
TabHeight = 794
ShowFocusRect = 0 'False
TabCaption(0) = "Speaker Phone"
TabPicture(0) = "frmSpeakerPhone.frx":0000
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label5"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label4"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Label3"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Label2"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "Label1"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "UpDown1"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).Control(6)= "UpDown2"
Tab(0).Control(6).Enabled= 0 'False
Tab(0).Control(7)= "UpDown3"
Tab(0).Control(7).Enabled= 0 'False
Tab(0).Control(8)= "UpDown4"
Tab(0).Control(8).Enabled= 0 'False
Tab(0).Control(9)= "Text5"
Tab(0).Control(9).Enabled= 0 'False
Tab(0).Control(10)= "Text4"
Tab(0).Control(10).Enabled= 0 'False
Tab(0).Control(11)= "Text3"
Tab(0).Control(11).Enabled= 0 'False
Tab(0).Control(12)= "Text2"
Tab(0).Control(12).Enabled= 0 'False
Tab(0).ControlCount= 13
Begin VB.TextBox Text2
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 1440
TabIndex = 3
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text3
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 3840
TabIndex = 6
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text4
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 6000
TabIndex = 9
Text = "0"
Top = 600
Width = 735
End
Begin VB.TextBox Text5
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 8280
TabIndex = 12
Text = "0"
Top = 600
Width = 735
End
Begin ComCtl2.UpDown UpDown4
Height = 555
Left = 9000
TabIndex = 13
Top = 600
Width = 240
_ExtentX = 423
_ExtentY = 979
_Version = 327681
AutoBuddy = -1 'True
BuddyControl = "Text5"
BuddyDispid = 196612
OrigLeft = 9000
OrigTop = 600
OrigRight = 9240
OrigBottom = 1215
Max = 999
SyncBuddy = -1 'True
BuddyProperty = 0
Enabled = -1 'True
End
Begin ComCtl2.UpDown UpDown3
Height = 555
Left = 6720
TabIndex = 10
Top = 600
Width = 240
_ExtentX = 423
_ExtentY = 979
_Version = 327681
AutoBuddy = -1 'True
BuddyControl = "Text4"
BuddyDispid = 196611
OrigLeft = 2520
OrigTop = 1080
OrigRight = 2760
OrigBottom = 1695
Max = 999
SyncBuddy = -1 'True
BuddyProperty = 0
Enabled = -1 'True
End
Begin ComCtl2.UpDown UpDown2
Height = 555
Left = 4560
TabIndex = 7
Top = 600
Width = 240
_ExtentX = 423
_ExtentY = 979
_Version = 327681
AutoBuddy = -1 'True
BuddyControl = "Text3"
BuddyDispid = 196610
OrigLeft = 5400
OrigTop = 360
OrigRight = 5640
OrigBottom = 975
Max = 999
SyncBuddy = -1 'True
BuddyProperty = 0
Enabled = -1 'True
End
Begin ComCtl2.UpDown UpDown1
Height = 555
Left = 2160
TabIndex = 4
Top = 600
Width = 240
_ExtentX = 423
_ExtentY = 979
_Version = 327681
AutoBuddy = -1 'True
BuddyControl = "Text2"
BuddyDispid = 196609
OrigLeft = 2520
OrigTop = 360
OrigRight = 2760
OrigBottom = 975
Max = 999
SyncBuddy = -1 'True
BuddyProperty = 0
Enabled = -1 'True
End
Begin VB.Label Label1
Caption = "Max. &Volume:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 120
TabIndex = 2
Top = 735
Width = 1215
End
Begin VB.Label Label2
Caption = "Min. V&olume:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2520
TabIndex = 5
Top = 735
Width = 1215
End
Begin VB.Label Label3
Caption = "Max. &Gain:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4920
TabIndex = 8
Top = 735
Width = 1095
End
Begin VB.Label Label4
Caption = "<NAME>:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 7080
TabIndex = 11
Top = 735
Width = 1095
End
Begin VB.Label Label5
Caption = $"frmSpeakerPhone.frx":001C
Height = 615
Left = 120
TabIndex = 15
Top = 1395
Width = 9015
End
End
Begin VB.TextBox Text1
Height = 285
Left = 0
TabIndex = 0
Text = "HKR,, SpeakerPhoneSpecs,1, 00,00,00,00, 0f,00,00,00, 03,00,00,00, 00,00,00,00"
Top = 0
Width = 9495
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 300
Left = 0
TabIndex = 14
Top = 5430
Width = 9480
_ExtentX = 16722
_ExtentY = 529
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
AutoSize = 1
Object.Width = 13070
TextSave = ""
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "5/12/98"
Key = ""
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
AutoSize = 2
Object.Width = 1773
MinWidth = 1764
TextSave = "4:22 PM"
Key = ""
Object.Tag = ""
EndProperty
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "frmSpeakerPhone"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim FirstDword As String
Dim SecondDword As String
Dim ThirdDword As String
Dim FourthDword As String
Dim FirstBit1 As Variant
Dim SecondBit1 As Variant
Dim ThirdBit1 As Variant
Dim FourthBit1 As Variant
Dim FirstBit2 As Variant
Dim SecondBit2 As Variant
Dim ThirdBit2 As Variant
Dim FourthBit2 As Variant
Dim FirstBit3 As Variant
Dim SecondBit3 As Variant
Dim ThirdBit3 As Variant
Dim FourthBit3 As Variant
Dim FirstBit4 As Variant
Dim SecondBit4 As Variant
Dim ThirdBit4 As Variant
Dim FourthBit4 As Variant
Dim Which As Integer
Public Sub ClearControl()
FirstDword = "00,00,00,00"
SecondDword = "00,00,00,00"
ThirdDword = "00,00,00,00"
FourthDword = "00,00,00,00"
Text2.Text = "0"
Text3.Text = "0"
Text4.Text = "0"
Text5.Text = "0"
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FirstDword)
If frmSpeakerPhone.Visible = False Then
frmSpeakerPhone.Visible = True
End If
Text1.SetFocus
End Sub
Public Sub EditCopy()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text1.SetFocus
Clipboard.Clear
Clipboard.SetText Text1.Text
End Sub
Public Sub EditPaste()
GetWord (Clipboard.GetText)
FirstDword = FirstBit1 & "," & SecondBit1 & "," & ThirdBit1 & "," & FourthBit1
SecondDword = FirstBit2 & "," & SecondBit2 & "," & ThirdBit2 & "," & FourthBit2
ThirdDword = FirstBit3 & "," & SecondBit3 & "," & ThirdBit3 & "," & FourthBit3
FourthDword = FirstBit4 & "," & SecondBit4 & "," & ThirdBit4 & "," & FourthBit4
Text2.Text = CDec(H & FourthBit1 & ThirdBit1 & SecondBit1 & FirstBit1)
Text3.Text = CDec(H & FourthBit2 & ThirdBit2 & SecondBit2 & FirstBit2)
Text4.Text = CDec(H & FourthBit3 & ThirdBit3 & SecondBit3 & FirstBit3)
Text5.Text = CDec(H & FourthBit4 & ThirdBit4 & SecondBit4 & FirstBit4)
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FirstDword)
If frmSpeakerPhone.Visible = False Then
frmSpeakerPhone.Visible = True
End If
Text1.SetFocus
End Sub
Private Sub Form_Load()
ClearControl
End Sub
Private Sub Form_Resize()
Text1.Width = frmSpeakerPhone.Width
Label5.Width = frmSpeakerPhone.Width - 255
SSTab1.Width = frmSpeakerPhone.Width - 75
SSTab1.Height = frmSpeakerPhone.Height - 675
End Sub
Public Sub Update()
Text1.Text = "HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", " & SecondDword & ", " & ThirdDword & ", " & FourthDword
End Sub
Private Sub Text2_DblClick()
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FirstDword)
Text1.SetFocus
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UpDown1_Change
End If
End Sub
Private Sub Text2_LostFocus()
UpDown1_Change
End Sub
Private Sub Text3_DblClick()
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(SecondDword)
Text1.SetFocus
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UpDown2_Change
End If
End Sub
Private Sub Text3_LostFocus()
UpDown2_Change
End Sub
Private Sub Text4_DblClick()
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", " & SecondDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(ThirdDword)
Text1.SetFocus
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UpDown3_Change
End If
End Sub
Private Sub Text4_LostFocus()
UpDown3_Change
End Sub
Private Sub Text5_DblClick()
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", " & SecondDword & ", " & ThirdDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FourthDword)
Text1.SetFocus
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
UpDown4_Change
End If
End Sub
Private Sub Text5_LostFocus()
UpDown4_Change
End Sub
Private Sub UpDown1_Change()
HexCon (Text2.Text)
FirstDword = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FirstDword)
Text1.SetFocus
Which = 1
End Sub
Private Sub UpDown2_Change()
HexCon (Text3.Text)
SecondDword = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(SecondDword)
Text1.SetFocus
Which = 2
End Sub
Private Sub UpDown3_Change()
HexCon (Text4.Text)
ThirdDword = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", " & SecondDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(ThirdDword)
Text1.SetFocus
Which = 3
End Sub
Private Sub UpDown4_Change()
HexCon (Text5.Text)
FourthDword = HexNum
Update
Dim strFirst As String
strFirst = Len("HKR,, SpeakerPhoneSpecs,1, " & FirstDword & ", " & SecondDword & ", " & ThirdDword & ", ")
Text1.SelStart = strFirst
Text1.SelLength = Len(FourthDword)
Text1.SetFocus
Which = 4
End Sub
Public Sub GetWord(strString As String)
Dim strSubString As String
Dim lStart As Long
Dim lStop As Long
lStart = 1
lStop = Len(strString)
While lStart < lStop And "," <> Mid$(strString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strString, lStop + 1, 1) And lStop <= Len(strString) ' Loop until next , found
lStop = lStop + 1
Wend
strSubString = Mid$(strString, lStop + 2)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until next , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until next , found
lStop = lStop + 1
Wend
strSubString = Mid$(strSubString, lStop + 1)
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until next , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until next , found
lStop = lStop + 1
Wend
FirstBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FirstBit1)
FirstBit1 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
SecondBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (SecondBit1)
SecondBit1 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
ThirdBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (ThirdBit1)
ThirdBit1 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FourthBit1 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FourthBit1)
FourthBit1 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FirstBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FirstBit2)
FirstBit2 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
SecondBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (SecondBit2)
SecondBit2 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
ThirdBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (ThirdBit2)
ThirdBit2 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FourthBit2 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FourthBit2)
FourthBit2 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FirstBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FirstBit3)
FirstBit3 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) And " " <> Mid$(strSubString, lStop + 1, 1) And vbTab <> Mid$(strSubString, lStop + 1, 1) ' Loop until last , found
lStop = lStop + 1
Wend
SecondBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (SecondBit3)
SecondBit3 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until next , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until next , found
lStop = lStop + 1
Wend
ThirdBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (ThirdBit3)
ThirdBit3 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FourthBit3 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FourthBit3)
FourthBit3 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FirstBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FirstBit4)
FirstBit4 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
SecondBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (SecondBit4)
SecondBit4 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
ThirdBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (ThirdBit4)
ThirdBit4 = CleanNum
lStart = 1
lStop = Len(strSubString)
While lStart < lStop And "," <> Mid$(strSubString, lStart, 1) ' Loop until first , found
lStart = lStart + 1
Wend
lStop = lStart
While "," <> Mid$(strSubString, lStop + 1, 1) And lStop <= Len(strSubString) ' Loop until last , found
lStop = lStop + 1
Wend
FourthBit4 = Mid$(strSubString, lStart + 1, lStop - 1) ' Grab word found between ,'s
strSubString = Mid$(strSubString, lStop + 1)
Clean (FourthBit4)
FourthBit4 = CleanNum
End Sub
Private Sub Text1_Click()
Dim Start As Integer
Start = Text1.SelStart
If 25 < Start And Start < 39 Then
If Which = 1 Then Exit Sub
Text1.SelStart = 27
Text1.SelLength = 11
Text1.SetFocus
Which = 1
End If
If 38 < Start And Start < 52 Then
If Which = 2 Then Exit Sub
Text1.SelStart = 40
Text1.SelLength = 11
Text1.SetFocus
Which = 2
End If
If 51 < Start And Start < 65 Then
If Which = 3 Then Exit Sub
Text1.SelStart = 53
Text1.SelLength = 11
Text1.SetFocus
Which = 3
End If
If 64 < Start And Start < 78 Then
If Which = 4 Then Exit Sub
Text1.SelStart = 66
Text1.SelLength = 11
Text1.SetFocus
Which = 4
End If
'MsgBox Start
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Clipboard.Clear
Clipboard.SetText Text1.Text
EditPaste
End If
End Sub
|
<gh_stars>10-100
' Syntax Highlighting test file for VBScript
' Comments look like this
function hello(name) 'comment for function
on error resume next
dim x,y
if name<>"World" then
for x = 1 to 10
wscript.echo "Hello " & name
next
else
x=0
do while x<10
wscript.echo "Hello World"
x=x+1
loop
end if
hello=x+y
end function
Public Function testPublicFunct()
dim c,d
end Sub
sub testStub()
dim a,b
end sub
Public Sub testPublicSub()
dim c,d
end Sub
'---------------------------
on error resume next
dim didIt
dim userid
set WshShell = WScript.CreateObject("WScript.Shell")
'Finds the user name from an environment variable
userid=wshshell.expandenvironmentstrings("%username%")
didIt=hello(userid)
wscript.exit(0)
|
Private mvarValue As Integer
Public Property Let Value(ByVal vData As Integer)
If (vData > 10) Or (vData < 1) Then
Error 380 'Invalid property value; could also use 6, Overflow
Else
mvarValue = vData
End If
End Property
Public Property Get Value() As Integer
Value = mvarValue
End Property
Private Sub Class_Initialize()
'vb defaults to 0 for numbers; let's change that...
mvarValue = 1
End Sub
|
on error resume next
const wbemPrivilegeShutdown = 18
set locator = CreateObject("WbemScripting.SWbemLocator")
locator.security_.privileges.Add wbemPrivilegeShutdown
set service = locator.connectserver
service.security_.impersonationLevel = 3
set osset = service.instancesof ("Win32_OperatingSystem")
for each os in osset
result = os.Shutdown ()
if err <> 0 then
WScript.Echo Hex(Err.Number), Err.Description
else
WScript.Echo "Shutdown returned result " & result
end if
next
|
<gh_stars>10-100
'
' This sample illustrates how to retrieve perfmon counter values from WMI. Note that the accompanying MOF
' (perfmon.mof) must be compiled and loaded for this sample to run correctly.
'
set processes = GetObject("winmgmts:{impersonationLevel=impersonate}!root/perfmonScriptExample").InstancesOf ("NTProcesses")
WScript.Echo "Displaying Process Counters"
WScript.Echo "==========================="
WScript.Echo
for each process in processes
WScript.Echo " " & process.Process & ": #Threads=" & process.Threads & " Working Set=" & process.WorkingSet
WScript.Echo
next
WScript.Echo "Displaying Memory Counters"
WScript.Echo "=========================="
WScript.Echo
set memorySet = GetObject("winmgmts:{impersonationLevel=impersonate}!root/perfmonScriptExample").InstancesOf ("NTMemory")
for each memoryItem in memorySet
WScript.Echo " " & memoryItem.Memory & ": Committed Bytes=" & memoryItem.CommittedBytes
next
|
Sub magic_square(n)
Dim ms()
ReDim ms(n-1,n-1)
inc = 0
count = 1
row = 0
col = Int(n/2)
Do While count <= n*n
ms(row,col) = count
count = count + 1
If inc < n-1 Then
inc = inc + 1
row = row - 1
col = col + 1
If row >= 0 Then
If col > n-1 Then
col = 0
End If
Else
row = n-1
End If
Else
inc = 0
row = row + 1
End If
Loop
For i = 0 To n-1
For j = 0 To n-1
If j = n-1 Then
WScript.StdOut.Write ms(i,j)
Else
WScript.StdOut.Write ms(i,j) & vbTab
End If
Next
WScript.StdOut.WriteLine
Next
End Sub
magic_square(5)
|
Option Explicit
Dim i, j, s
For i = 1 To 5
s = ""
For j = 1 To i
s = s + "*"
Next
WScript.Echo s
Next
|
<gh_stars>1-10
'This is the string we want to "evolve" to. Any string of any length will
'do as long as it consists only of upper case letters and spaces.
Target = "METHINKS IT IS LIKE A WEASEL"
'This is the pool of letters that will be selected at random for a mutation
letters = " <KEY>"
'A mutation rate of 0.5 means that there is a 50% chance that one letter
'will be mutated at random in the next child
mutation_rate = 0.5
'Set for 10 children per generation
Dim child(10)
'Generate the first guess as random letters
Randomize
Parent = ""
for i = 1 to len(Target)
Parent = Parent & Mid(letters,Random(1,Len(letters)),1)
next
gen = 0
Do
bestfit = 0
bestind = 0
gen = gen + 1
'make n copies of the current string and find the one
'that best matches the target string
For i = 0 to ubound(child)
child(i) = Mutate(Parent, mutation_rate)
fit = Fitness(Target, child(i))
If fit > bestfit Then
bestfit = fit
bestind = i
End If
Next
'Select the child that has the best fit with the target string
Parent = child(bestind)
Wscript.Echo parent, "(fit=" & bestfit & ")"
Loop Until Parent = Target
Wscript.Echo vbcrlf & "Generations = " & gen
'apply a random mutation to a random character in a string
Function Mutate ( ByVal str , ByVal rate )
Dim pos 'a random position in the string'
Dim ltr 'a new letter chosen at random '
If rate > Rnd(1) Then
ltr = Mid(letters,Random(1,len(letters)),1)
pos = Random(1,len(str))
str = Left(str, pos - 1) & ltr & Mid(str, pos + 1)
End If
Mutate = str
End Function
'returns the number of letters in the two strings that match
Function Fitness (ByVal str , ByVal ref )
Dim i
Fitness = 0
For i = 1 To Len(str)
If Mid(str, i, 1) = Mid(ref, i, 1) Then Fitness = Fitness + 1
Next
End Function
'Return a random integer in the range lower to upper (inclusive)
Private Function Random ( lower , upper )
Random = Int((upper - lower + 1) * Rnd + lower)
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData<gh_stars>1-10
Option Explicit
Private Type MyPoint
X As Single
Y As Single
End Type
Private Type MyPair
p1 As MyPoint
p2 As MyPoint
End Type
Sub Main()
Dim points() As MyPoint, i As Long, BF As MyPair, d As Single, Nb As Long
Dim T#
Randomize Timer
Nb = 10
Do
ReDim points(1 To Nb)
For i = 1 To Nb
points(i).X = Rnd * Nb
points(i).Y = Rnd * Nb
Next
d = 1000000000000#
T = Timer
BF = BruteForce(points, d)
Debug.Print "For " & Nb & " points, runtime : " & Timer - T & " sec."
Debug.Print "point 1 : X:" & BF.p1.X & " Y:" & BF.p1.Y
Debug.Print "point 2 : X:" & BF.p2.X & " Y:" & BF.p2.Y
Debug.Print "dist : " & d
Debug.Print "--------------------------------------------------"
Nb = Nb * 10
Loop While Nb <= 10000
End Sub
Private Function BruteForce(p() As MyPoint, mindist As Single) As MyPair
Dim i As Long, j As Long, d As Single, ClosestPair As MyPair
For i = 1 To UBound(p) - 1
For j = i + 1 To UBound(p)
d = Dist(p(i), p(j))
If d < mindist Then
mindist = d
ClosestPair.p1 = p(i)
ClosestPair.p2 = p(j)
End If
Next
Next
BruteForce = ClosestPair
End Function
Private Function Dist(p1 As MyPoint, p2 As MyPoint) As Single
Dist = Sqr((p1.X - p2.X) ^ 2 + (p1.Y - p2.Y) ^ 2)
End Function
|
'***********************************************************************
'*
'* WbemSink_OnCompleted
'*
'***********************************************************************
sub WbemSink_OnCompleted(hResult, pErrorObject, pAsyncContext)
WScript.Echo "Final status is:", hResult
end sub
'***********************************************************************
'*
'* WbemSink_OnObjectReady
'*
'***********************************************************************
sub WbemSink_OnObjectReady(pObject, pAsyncContext)
Set pObject = Nothing
end sub
Dim Service
Dim MyObect
Set MySink = Wscript.CreateObject ("Wbemscripting.SWbemSink", "WbemSink_")
Set Service = GetObject ("Winmgmts:")
for i = 1 to 1000
Service.GetAsync MySink, "win32_Service"
next
while true
Service.Get "Win32_Service"
wend
|
<gh_stars>1-10
Class MainForm
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MessageBox.Show("Hello, world!")
End Sub
End Class
|
<gh_stars>1-10
Private Function hailstone(ByVal n As Long) As Collection
Dim s As New Collection
s.Add CStr(n), CStr(n)
i = 0
Do While n <> 1
If n Mod 2 = 0 Then
n = n / 2
Else
n = 3 * n + 1
End If
s.Add CStr(n), CStr(n)
Loop
Set hailstone = s
End Function
Private Function hailstone_count(ByVal n As Long)
Dim count As Long: count = 1
Do While n <> 1
If n Mod 2 = 0 Then
n = n / 2
Else
n = 3 * n + 1
End If
count = count + 1
Loop
hailstone_count = count
End Function
Public Sub rosetta()
Dim s As Collection, i As Long
Set s = hailstone(27)
Dim ls As Integer: ls = s.count
Debug.Print "hailstone(27) = ";
For i = 1 To 4
Debug.Print s(i); ", ";
Next i
Debug.Print "... ";
For i = s.count - 4 To s.count - 1
Debug.Print s(i); ", ";
Next i
Debug.Print s(s.count)
Debug.Print "length ="; ls
Dim hmax As Long: hmax = 1
Dim imax As Long: imax = 1
Dim count As Integer
For i = 2 To 100000# - 1
count = hailstone_count(i)
If count > hmax Then
hmax = count
imax = i
End If
Next i
Debug.Print "The longest hailstone sequence under 100,000 is"; imax; "with"; hmax; "elements."
End Sub
|
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain
Caption = "HHTs To MDB"
ClientHeight = 5685
ClientLeft = 60
ClientTop = 345
ClientWidth = 7095
LinkTopic = "Form1"
ScaleHeight = 5685
ScaleWidth = 7095
StartUpPosition = 3 'Windows Default
Begin VB.CheckBox chkNoTaxonomy
Caption = "&Ignore Taxonomy"
Height = 255
Left = 120
TabIndex = 11
Top = 1320
Width = 1575
End
Begin VB.ComboBox cboSKU
Height = 315
Left = 1080
Style = 2 'Dropdown List
TabIndex = 10
Top = 840
Width = 5535
End
Begin VB.TextBox txtOutput
Height = 3765
Left = 120
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 8
Top = 1800
Width = 6855
End
Begin VB.CommandButton cmdClose
Caption = "Close"
Height = 375
Left = 6120
TabIndex = 7
Top = 1320
Width = 855
End
Begin VB.CommandButton cmdGo
Caption = "Go"
Height = 375
Left = 5040
TabIndex = 6
Top = 1320
Width = 975
End
Begin VB.CommandButton cmdMDB
Caption = "..."
Height = 255
Left = 6720
TabIndex = 5
Top = 480
Width = 255
End
Begin MSComDlg.CommonDialog dlgCommon
Left = 4440
Top = 1200
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox txtMDB
Height = 285
Left = 1080
TabIndex = 4
Top = 480
Width = 5535
End
Begin VB.CommandButton cmdFolder
Caption = "..."
Height = 255
Left = 6720
TabIndex = 2
Top = 120
Width = 255
End
Begin VB.TextBox txtFolder
Height = 285
Left = 1080
TabIndex = 1
Top = 120
Width = 5535
End
Begin VB.Label lblSKU
Caption = "&SKU"
Height = 255
Left = 120
TabIndex = 9
Top = 840
Width = 855
End
Begin VB.Label lblMDB
Caption = "&MDB file"
Height = 255
Left = 120
TabIndex = 3
Top = 480
Width = 855
End
Begin VB.Label lblFolder
Caption = "HH&Ts folder"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 855
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' Make sure that these letters correspond to the Alt key combinations.
Private Const OPT_HHT_FOLDER_C As String = "t"
Private Const OPT_MDB_FILE_C As String = "m"
Private Const OPT_SKU_C As String = "s"
Private Const OPT_IGNORE_TAXONOMY_C As String = "i"
Private Const OPT_CLOSE_ON_WARNING_C As String = "qw"
Private Const OPT_CLOSE_ALWAYS_C As String = "qa"
Private Const OPT_HELP_C As String = "h,?,help"
Private p_strSeparator As String
Private p_blnWarning As Boolean
Private p_blnError As Boolean
Private p_clsSizer As Sizer
Private WithEvents p_frmFolderChooser As frmFolderChooser
Attribute p_frmFolderChooser.VB_VarHelpID = -1
Private Sub p_DisplayHelp()
Dim str As String
str = "Usage: " & vbCrLf & vbCrLf & _
App.EXEName & " /t <HHTs folder> /m <MDB file> /s <SKU> /i /qw /qa" & vbCrLf & vbCrLf & _
"The /i, /qw, and /qa arguments are optional." & vbCrLf & _
"/qw makes the window go away even if there are Warnings." & vbCrLf & _
"/qa makes the window go away even if there are Errors and/or Warnings." & vbCrLf & _
"""" & App.EXEName & " /?"" displays this message."
Output str, LOGGING_TYPE_NORMAL_E
Output p_strSeparator, LOGGING_TYPE_NORMAL_E
End Sub
Private Sub Form_Load()
cmdGo.Default = True
cmdClose.Cancel = True
PopulateCboWithSKUs cboSKU
Set p_clsSizer = New Sizer
Set p_frmFolderChooser = New frmFolderChooser
SetLogFile
Output "Version " & App.Major & "." & App.Minor & "." & App.Revision, LOGGING_TYPE_NORMAL_E
Output "Currently, this tool has the following limitations: ", LOGGING_TYPE_NORMAL_E
Output "1) It can only handle ADDs in the HHTs. It cannot handle DELs.", LOGGING_TYPE_NORMAL_E
Output "2) It cannot handle the Attribute INSERTMODE.", LOGGING_TYPE_NORMAL_E
Output "3) It assumes that there are no synonym sets currently in the database.", LOGGING_TYPE_NORMAL_E
p_strSeparator = String(80, "-")
Output p_strSeparator, LOGGING_TYPE_NORMAL_E
p_ProcessCommandLine
End Sub
Private Sub p_ProcessCommandLine()
Dim strCommand As String
Dim strSKU As String
Dim intIndex As Long
Dim blnCloseOnWarning As Boolean
Dim blnCloseAlways As Boolean
Dim blnClose As Boolean
strCommand = Trim$(Command$)
If (strCommand = "") Then
Exit Sub
End If
txtFolder = GetOption(strCommand, OPT_HHT_FOLDER_C, True)
txtMDB = GetOption(strCommand, OPT_MDB_FILE_C, True)
strSKU = GetOption(strCommand, OPT_SKU_C, True)
cboSKU.ListIndex = -1
If (IsNumeric(strSKU)) Then
For intIndex = 0 To cboSKU.ListCount - 1
If (cboSKU.ItemData(intIndex) = strSKU) Then
cboSKU.ListIndex = intIndex
Exit For
End If
Next
End If
If (OptionExists(strCommand, OPT_IGNORE_TAXONOMY_C, True)) Then
chkNoTaxonomy.Value = vbChecked
End If
blnCloseOnWarning = OptionExists(strCommand, OPT_CLOSE_ON_WARNING_C, True)
blnCloseAlways = OptionExists(strCommand, OPT_CLOSE_ALWAYS_C, True)
If (OptionExists(strCommand, OPT_HELP_C, True)) Then
p_DisplayHelp
ElseIf (Len(strCommand) <> 0) Then
cmdGo_Click
If (p_blnError) Then
' If an error occurred, then close the window only if OPT_CLOSE_ALWAYS_C is specified.
If (blnCloseAlways) Then
blnClose = True
End If
ElseIf (p_blnWarning) Then
' If a warning occurred, but there was no error, then close the window only if
' OPT_CLOSE_ON_WARNING_C or OPT_CLOSE_ALWAYS_C is specified.
If (blnCloseOnWarning Or blnCloseAlways) Then
blnClose = True
End If
Else
' If there was no warning or error, then close the window.
blnClose = True
End If
If (blnClose) Then
cmdClose_Click
End If
End If
End Sub
Private Sub cmdGo_Click()
On Error GoTo LError
Dim strHHTsFolder As String
Dim strMDBFile As String
Dim blnIgnoreTaxonomy As Boolean
Output "Start: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
strHHTsFolder = Trim$(txtFolder.Text)
strMDBFile = Trim$(txtMDB.Text)
If (chkNoTaxonomy.Value = vbChecked) Then
blnIgnoreTaxonomy = True
End If
If ((strHHTsFolder = "") Or (strMDBFile = "")) Then
Output "Please specify the HHTs folder and MDB file", LOGGING_TYPE_ERROR_E
GoTo LError
End If
If ((Not blnIgnoreTaxonomy) And (cboSKU.ListIndex = -1)) Then
Output "Please specify the SKU", LOGGING_TYPE_ERROR_E
GoTo LError
End If
Me.Enabled = False
ImportHHTs2MDB strHHTsFolder, strMDBFile, cboSKU.ItemData(cboSKU.ListIndex), blnIgnoreTaxonomy
LEnd:
Output "End: " & Date & " " & Time, LOGGING_TYPE_NORMAL_E
Output "The log file is: " & GetLogFileName, LOGGING_TYPE_NORMAL_E
Output p_strSeparator, LOGGING_TYPE_NORMAL_E
Me.Enabled = True
Exit Sub
LError:
GoTo LEnd
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdFolder_Click()
Load p_frmFolderChooser
p_frmFolderChooser.SetFolder 0, txtFolder.Text
p_frmFolderChooser.Show vbModal
End Sub
Private Sub cmdMDB_Click()
On Error GoTo LError
dlgCommon.CancelError = True
dlgCommon.Flags = cdlOFNHideReadOnly
dlgCommon.Filter = "Microsoft Access Files (*.mdb)|*.mdb"
dlgCommon.ShowOpen
txtMDB.Text = dlgCommon.FileName
LEnd:
Exit Sub
LError:
Select Case Err.Number
Case cdlCancel
' Nothing. The user cancelled.
End Select
GoTo LEnd
End Sub
Private Sub p_frmFolderChooser_FolderChosen( _
ByVal i_intIndex As Long, _
ByVal strFolder As String _
)
txtFolder.Text = strFolder
End Sub
Private Sub Form_Activate()
On Error GoTo LError
p_SetSizingInfo
DoEvents
LError:
End Sub
Private Sub Form_Resize()
On Error GoTo LError
p_clsSizer.Resize
LError:
End Sub
Private Sub p_SetSizingInfo()
p_clsSizer.AddControl txtFolder
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdFolder
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl txtMDB
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdMDB
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cboSKU
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdGo
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl cmdClose
Set p_clsSizer.ReferenceControl(DIM_LEFT_E) = Me
p_clsSizer.ReferenceDimension(DIM_LEFT_E) = DIM_WIDTH_E
p_clsSizer.AddControl txtOutput
Set p_clsSizer.ReferenceControl(DIM_RIGHT_E) = Me
p_clsSizer.ReferenceDimension(DIM_RIGHT_E) = DIM_WIDTH_E
Set p_clsSizer.ReferenceControl(DIM_BOTTOM_E) = Me
p_clsSizer.ReferenceDimension(DIM_BOTTOM_E) = DIM_HEIGHT_E
End Sub
Public Sub Output( _
ByVal i_str As String, _
ByVal i_enumLoggingType As LOGGING_TYPE_E _
)
OutputToTextBoxAndWriteLog txtOutput, i_str, i_enumLoggingType
If (i_enumLoggingType = LOGGING_TYPE_ERROR_E) Then
p_blnError = True
ElseIf (i_enumLoggingType = LOGGING_TYPE_WARNING_E) Then
p_blnWarning = True
End If
End Sub
|
<gh_stars>1-10
function Squish( s1 )
dim sRes
sRes = vbNullString
dim i, c
for i = 1 to len( s1 )
c = lcase( mid( s1, i, 1 ))
if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then
sRes = sRes & c
end if
next
Squish = sRes
end function
function isPalindrome( s1 )
dim squished
squished = Squish( s1 )
isPalindrome = ( squished = StrReverse( squished ) )
end function
|
n = 8
arr = Identity(n)
for i = 0 to n-1
for j = 0 to n-1
wscript.stdout.Write arr(i,j) & " "
next
wscript.stdout.writeline
next
Function Identity (size)
Execute Replace("dim a(#,#):for i=0 to #:for j=0 to #:a(i,j)=0:next:a(i,i)=1:next","#",size-1)
Identity = a
End Function
|
Option Explicit
Sub Main_Romans_Decode()
Dim Arr(), i&
Arr = Array("III", "XXX", "CCC", "MMM", "VII", "LXVI", "CL", "MCC", "IV", "IX", "XC", "ICM", "DCCCXCIX", "CMI", "CIM", "MDCLXVI", "MCMXC", "MMXVII")
For i = 0 To UBound(Arr)
Debug.Print Arr(i) & " >>> " & lngConvert(CStr(Arr(i)))
Next
End Sub
Function Convert(Letter As String) As Long
Dim Romans(), DecInt(), Pos As Integer
Romans = Array("M", "D", "C", "L", "X", "V", "I")
DecInt = Array(1000, 500, 100, 50, 10, 5, 1)
Pos = -1
On Error Resume Next
Pos = Application.Match(Letter, Romans, 0) - 1
On Error GoTo 0
If Pos <> -1 Then Convert = DecInt(Pos)
End Function
Function lngConvert(strRom As String) 'recursive function
Dim i As Long, iVal As Integer
If Len(strRom) = 1 Then
lngConvert = Convert(strRom)
Else
iVal = Convert(Mid(strRom, 1, 1))
If iVal < Convert(Mid(strRom, 2, 1)) Then iVal = iVal * (-1)
lngConvert = iVal + lngConvert(Mid(strRom, 2, Len(strRom) - 1))
End If
End Function
|
Option Explicit
Private Lines(1 To 3, 1 To 3) As String
Private Nb As Byte, player As Byte
Private GameWin As Boolean, GameOver As Boolean
Sub Main_TicTacToe()
Dim p As String
InitLines
printLines Nb
Do
p = WhoPlay
Debug.Print p & " play"
If p = "Human" Then
Call HumanPlay
GameWin = IsWinner("X")
Else
Call ComputerPlay
GameWin = IsWinner("O")
End If
If Not GameWin Then GameOver = IsEnd
Loop Until GameWin Or GameOver
If Not GameOver Then
Debug.Print p & " Win !"
Else
Debug.Print "Game Over!"
End If
End Sub
Sub InitLines(Optional S As String)
Dim i As Byte, j As Byte
Nb = 0: player = 0
For i = LBound(Lines, 1) To UBound(Lines, 1)
For j = LBound(Lines, 2) To UBound(Lines, 2)
Lines(i, j) = "#"
Next j
Next i
End Sub
Sub printLines(Nb As Byte)
Dim i As Byte, j As Byte, strT As String
Debug.Print "Loop " & Nb
For i = LBound(Lines, 1) To UBound(Lines, 1)
For j = LBound(Lines, 2) To UBound(Lines, 2)
strT = strT & Lines(i, j)
Next j
Debug.Print strT
strT = vbNullString
Next i
End Sub
Function WhoPlay(Optional S As String) As String
If player = 0 Then
player = 1
WhoPlay = "Human"
Else
player = 0
WhoPlay = "Computer"
End If
End Function
Sub HumanPlay(Optional S As String)
Dim L As Byte, C As Byte, GoodPlay As Boolean
Do
L = Application.InputBox("Choose the row", "Numeric only", Type:=1)
If L > 0 And L < 4 Then
C = Application.InputBox("Choose the column", "Numeric only", Type:=1)
If C > 0 And C < 4 Then
If Lines(L, C) = "#" And Not Lines(L, C) = "X" And Not Lines(L, C) = "O" Then
Lines(L, C) = "X"
Nb = Nb + 1
printLines Nb
GoodPlay = True
End If
End If
End If
Loop Until GoodPlay
End Sub
Sub ComputerPlay(Optional S As String)
Dim L As Byte, C As Byte, GoodPlay As Boolean
Randomize Timer
Do
L = Int((Rnd * 3) + 1)
C = Int((Rnd * 3) + 1)
If Lines(L, C) = "#" And Not Lines(L, C) = "X" And Not Lines(L, C) = "O" Then
Lines(L, C) = "O"
Nb = Nb + 1
printLines Nb
GoodPlay = True
End If
Loop Until GoodPlay
End Sub
Function IsWinner(S As String) As Boolean
Dim i As Byte, j As Byte, Ch As String, strTL As String, strTC As String
Ch = String(UBound(Lines, 1), S)
'check lines & columns
For i = LBound(Lines, 1) To UBound(Lines, 1)
For j = LBound(Lines, 2) To UBound(Lines, 2)
strTL = strTL & Lines(i, j)
strTC = strTC & Lines(j, i)
Next j
If strTL = Ch Or strTC = Ch Then IsWinner = True: Exit For
strTL = vbNullString: strTC = vbNullString
Next i
'check diagonales
strTL = Lines(1, 1) & Lines(2, 2) & Lines(3, 3)
strTC = Lines(1, 3) & Lines(2, 2) & Lines(3, 1)
If strTL = Ch Or strTC = Ch Then IsWinner = True
End Function
Function IsEnd() As Boolean
Dim i As Byte, j As Byte
For i = LBound(Lines, 1) To UBound(Lines, 1)
For j = LBound(Lines, 2) To UBound(Lines, 2)
If Lines(i, j) = "#" Then Exit Function
Next j
Next i
IsEnd = True
End Function
|
<reponame>LaudateCorpus1/RosettaCodeData
Public Function Reverse(aString as String) as String
' returns the reversed string
dim L as integer 'length of string
dim newString as string
newString = ""
L = len(aString)
for i = L to 1 step -1
newString = newString & mid$(aString, i, 1)
next
Reverse = newString
End Function
|
'***************************************************************************
'This script tests the GetInstance operation using XML/HTTP
'***************************************************************************
on error resume next
Dim objLocator
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Dim objService
Set objService = objLocator.ConnectServer("[http://localhost/cimom]", "root\cimv2")
if err <> 0 then
WScript.Echo ErrNumber, Err.Source, Err.Description
else
WScript.Echo "ConnectServer Succeeded"
end if
Set firstProcessor = objService.Get("win32_processor.DeviceID=""CPU0""")
if err <> 0 then
WScript.Echo ErrNumber, Err.Source, Err.Description
else
WScript.Echo firstProcessor.description
end if
|
Option Explicit
Sub Method_1(Optional myStr As String)
Dim strTemp As String
If myStr <> "" Then strTemp = myStr
Debug.Print strTemp
End Sub
Static Sub Method_2(Optional myStr As String)
Dim strTemp As String
If myStr <> "" Then strTemp = myStr
Debug.Print strTemp
End Sub
|
Option Explicit
Sub Main_Best_shuffle()
Dim S() As Long, W, b As Byte, Anagram$, Count&, myB As Boolean, Limit As Byte, i As Integer
W = Array("a", "abracadabra", "seesaw", "elk", "grrrrrr", "up", "qwerty", "tttt")
For b = 0 To UBound(W)
Count = 0
Select Case Len(W(b))
Case 1: Limit = 1
Case Else
i = NbLettersDiff(W(b))
If i >= Len(W(b)) \ 2 Then
Limit = 0
ElseIf i = 1 Then
Limit = Len(W(b))
Else
Limit = Len(W(b)) - i
End If
End Select
RePlay:
Do
S() = ShuffleIntegers(Len(W(b)))
myB = GoodShuffle(S, Limit)
Loop While Not myB
Anagram = ShuffleWord(CStr(W(b)), S)
Count = Nb(W(b), Anagram)
If Count > Limit Then GoTo RePlay
Debug.Print W(b) & " ==> " & Anagram & " (Score : " & Count & ")"
Next
End Sub
Function ShuffleIntegers(l As Long) As Long()
Dim i As Integer, ou As Integer, temp() As Long
Dim C As New Collection
ReDim temp(l - 1)
If l = 1 Then
temp(0) = 0
ElseIf l = 2 Then
temp(0) = 1: temp(1) = 0
Else
Randomize
Do
ou = Int(Rnd * l)
On Error Resume Next
C.Add CStr(ou), CStr(ou)
If Err <> 0 Then
On Error GoTo 0
Else
temp(ou) = i
i = i + 1
End If
Loop While C.Count <> l
End If
ShuffleIntegers = temp
End Function
Function GoodShuffle(t() As Long, Lim As Byte) As Boolean
Dim i&, C&
For i = LBound(t) To UBound(t)
If t(i) = i Then C = C + 1
Next i
GoodShuffle = (C <= Lim)
End Function
Function ShuffleWord(W$, S() As Long) As String
Dim i&, temp, strR$
temp = Split(StrConv(W, vbUnicode), Chr(0))
For i = 0 To UBound(S)
strR = strR & temp(S(i))
Next i
ShuffleWord = strR
End Function
Function Nb(W, A) As Integer
Dim i As Integer, l As Integer
For i = 1 To Len(W)
If Mid(W, i, 1) = Mid(A, i, 1) Then l = l + 1
Next i
Nb = l
End Function
Function NbLettersDiff(W) As Integer
Dim i&, C As New Collection
For i = 1 To Len(W)
On Error Resume Next
C.Add Mid(W, i, 1), Mid(W, i, 1)
Next i
NbLettersDiff = C.Count
End Function
|
<reponame>bluebat/mt9x9
#!/usr/bin/bas
rem 9x9 multiplication table in QBASIC
rem CC0, <NAME> <<EMAIL>>, 2018.
rem ./mt9x9.bas || bas mt9x9.bas
for i% = 1 to 9 step 3
for j% = 1 to 9
for k% = i% to i%+2
print using "#x#=##"+chr$(9); k%, j%, k%*j%;
next k%
print chr$(10);
next j%
print
next i%
|
<reponame>npocmaka/Windows-Server-2003
on error resume next
while true
Set Locator = CreateObject("WbemScripting.SWbemLocator")
WScript.Echo "Remote Case"
WScript.Echo "***********"
WScript.Echo ""
Set Service = Locator.ConnectServer ("ludlow","root\default")
if err <> 0 then
WScript.Echo "Error:-", Err.Description, Err.Number, Err.Source
end if
WScript.Echo Service.Security_.AuthenticationLevel
WScript.Echo Service.Security_.ImpersonationLevel
WScript.Echo "Local Case"
WScript.Echo "**********"
WScript.Echo ""
Set Service = Locator.ConnectServer
if err <> 0 then
WScript.Echo "Error:-", Err.Description, Err.Number, Err.Source
end if
WScript.Echo Service.Security_.AuthenticationLevel
WScript.Echo Service.Security_.ImpersonationLevel
wend
|
<reponame>LaudateCorpus1/RosettaCodeData
Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1 'Count
On Error Resume Next
Limite_Recursivite Cpt 'recurse
On Error GoTo 0
Limite_Recursivite = Cpt 'return
End Function
|
Option Explicit
Option Base 1
Function ShuntingYard(strInfix As String) As String
Dim i As Long, j As Long, token As String, tokenArray() As String
Dim stack() As Variant, queue() As Variant, discard As String
Dim op1 As String, op2 As String
Debug.Print strInfix
' Get tokens
tokenArray = Split(strInfix)
' Initialize array (removed later)
ReDim stack(1)
ReDim queue(1)
' Loop over tokens
Do While 1
i = i + 1
If i - 1 > UBound(tokenArray) Then
Exit Do
Else
token = tokenArray(i - 1) 'i-1 due to Split returning a Base 0
End If
If token = "" Then: Exit Do
' Print
Debug.Print i, token, Join(stack, ","), Join(queue, ",")
' If-loop over tokens (either brackets, operators, or numbers)
If token = "(" Then
stack = push(token, stack)
ElseIf token = ")" Then
While Peek(stack) <> "("
queue = push(pop(stack), queue)
Wend
discard = pop(stack) 'discard "("
ElseIf isOperator(token) Then
op1 = token
Do While (isOperator(Peek(stack)))
' Debug.Print Peek(stack)
op2 = Peek(stack)
If op2 <> "^" And precedence(op1) = precedence(op2) Then
'"^" is the only right-associative operator
queue = push(pop(stack), queue)
ElseIf precedence(op1$) < precedence(op2$) Then
queue = push(pop(stack), queue)
Else
Exit Do
End If
Loop
stack = push(op1, stack)
Else 'number
'actually, wrong operator could end up here, like say %
'If the token is a number, then add it to the output queue.
queue = push(CStr(token), queue)
End If
Loop
While stack(1) <> ""
If Peek(stack) = "(" Then Debug.Print "no matching ')'": End
queue = push(pop(stack), queue)
Wend
' Print final output
ShuntingYard = Join(queue, " ")
Debug.Print "Output:"
Debug.Print ShuntingYard
End Function
'------------------------------------------
Function isOperator(op As String) As Boolean
isOperator = InStr("+-*/^", op) <> 0 And Len(op$) = 1
End Function
Function precedence(op As String) As Integer
If isOperator(op$) Then
precedence = 1 _
- (InStr("+-*/^", op$) <> 0) _
- (InStr("*/^", op$) <> 0) _
- (InStr("^", op$) <> 0)
End If
End Function
'------------------------------------------
Function push(str, stack) As Variant
Dim out() As Variant, i As Long
If Not IsEmpty(stack(1)) Then
out = stack
ReDim Preserve out(1 To UBound(stack) + 1)
out(UBound(out)) = str
Else
ReDim out(1 To 1)
out(1) = str
End If
push = out
End Function
Function pop(stack)
pop = stack(UBound(stack))
If UBound(stack) > 1 Then
ReDim Preserve stack(1 To UBound(stack) - 1)
Else
stack(1) = ""
End If
End Function
Function Peek(stack)
Peek = stack(UBound(stack))
End Function
|
<filename>Task/QR-decomposition/VBA/qr-decomposition-2.vba
Public Sub least_squares()
x = [{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}]
y = [{1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321}]
Dim a() As Double
ReDim a(UBound(x), 3)
For i = 1 To UBound(x)
For j = 1 To 3
a(i, j) = x(i) ^ (j - 1)
Next j
Next i
result = QRHouseholder(a)
q = result(1)
r_ = result(2)
t = WorksheetFunction.Transpose(q)
b = matrix_mul(t, vtranspose(y))
Dim z(3) As Double
For k = 3 To 1 Step -1
Dim s As Double: s = 0
If k < 3 Then
For j = k + 1 To 3
s = s + r_(k, j) * z(j)
Next j
End If
z(k) = (b(k, 1) - s) / r_(k, k)
Next k
Debug.Print "Least-squares solution:",
For i = 1 To 3
Debug.Print Format(z(i), "0.#####"),
Next i
End Sub
|
Private Function dot_product(x As Variant, y As Variant) As Double
dot_product = WorksheetFunction.SumProduct(x, y)
End Function
Public Sub main()
Debug.Print dot_product([{1,3,-5}], [{4,-2,-1}])
End Sub
|
arr = Array("710889",_
"B0YBKJ",_
"406566",_
"B0YBLH",_
"228276",_
"B0YBKL",_
"557910",_
"B0YBKR",_
"585284",_
"B0YBKT",_
"12345",_
"A12345",_
"B00030")
For j = 0 To UBound(arr)
WScript.StdOut.Write arr(j) & getSEDOLCheckDigit(arr(j))
WScript.StdOut.WriteLine
Next
Function getSEDOLCheckDigit(str)
If Len(str) <> 6 Then
getSEDOLCheckDigit = " is invalid. Only 6 character strings are allowed."
Exit Function
End If
Set mult = CreateObject("Scripting.Dictionary")
With mult
.Add "1","1" : .Add "2", "3" : .Add "3", "1"
.Add "4","7" : .Add "5", "3" : .Add "6", "9"
End With
total = 0
For i = 1 To 6
s = Mid(str,i,1)
If s = "A" Or s = "E" Or s = "I" Or s = "O" Or s = "U" Then
getSEDOLCheckDigit = " is invalid. Vowels are not allowed."
Exit Function
End If
If Asc(s) >= 48 And Asc(s) <=57 Then
total = total + CInt(s) * CInt(mult.Item(CStr(i)))
Else
total = total + (Asc(s) - 55) * CInt(mult.Item(CStr(i)))
End If
Next
getSEDOLCheckDigit = (10 - total Mod 10) Mod 10
End Function
|
<filename>Task/Conditional-structures/VBA/conditional-structures-3.vba
Sub C_S_Select_Case()
'With Strings
Dim A$, C&
A = "Hello"
Select Case A
Case "World"
Debug.Print "A = World"
Case "Hello"
Debug.Print "A = Hello"
Case Else
Debug.Print "You make a mistake"
End Select
'With numerics
C = 11
Select Case C
Case Is <= 10
Debug.Print "C <= 10"
Case Is < 20, Is > 10
Debug.Print "10 < C < 20"
Case Is >= 20
Debug.Print "C >= 20"
End Select
'Select Case Boolean
'With Strings
Select Case False
Case A <> "Hello"
Debug.Print "A = Hello"
Case A Like "*orl*"
Debug.Print "A Not Like *orl*"
Case Else
Debug.Print "You make a mistake"
End Select 'return : "A = Hello"
'Other conditions's order
Select Case False
Case A Like "*orl*"
Debug.Print "A Not Like *orl*"
Case A <> "Hello"
Debug.Print "A = Hello"
Case Else
Debug.Print "You make a mistake"
End Select 'return : "A Not Like *orl*"
'With numerics
Select Case True
Case C <= 10
Debug.Print "C <= 10"
Case C < 20, C > 10
Debug.Print "10 < C < 20"
Case C >= 20
Debug.Print "C >= 20"
End Select
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData
Sub C_S_ElseIf()
Dim A$, B$
A = "Hello"
B = "World"
'test
If A = B Then Debug.Print A & " = " & B
'other syntax
If A = B Then
Debug.Print A & " = " & B
ElseIf A > B Then
Debug.Print A & " > " & B
Else
Debug.Print A & " < " & B
End If
End Sub
|
<filename>Task/Harshad-or-Niven-series/VBA/harshad-or-niven-series.vba
Option Explicit
Sub Main()
Dim i As Long, out As String, Count As Integer
Do
i = i + 1
If IsHarshad(i) Then out = out & i & ", ": Count = Count + 1
Loop While Count < 20
Debug.Print "First twenty Harshad numbers are : " & vbCrLf & out & "..."
i = 1000
Do
i = i + 1
Loop While Not IsHarshad(i)
Debug.Print "The first harshad number after 1000 is : " & i
End Sub
Function IsHarshad(sNumber As Long) As Boolean
Dim Summ As Long, i As Long, temp
temp = Split(StrConv(sNumber, vbUnicode), Chr(0))
For i = LBound(temp) To UBound(temp) - 1
Summ = Summ + temp(i)
Next i
IsHarshad = sNumber Mod Summ = 0
End Function
|
<gh_stars>10-100
<job id="Cluster Properties">
<reference guid="{f2e606e0-2631-11d1-89f1-00a0c90d061e}" version="1.0" />
<script language="VBScript">
Option Explicit
Dim oCluster
Dim oGroup
Dim oNode
Dim vPending
Set oCluster = CreateObject("MSCluster.Cluster")
oCluster.Open ("galenb-clus")
MsgBox oCluster.Name
set oGroup = oCluster.ResourceGroups.Item( "Test" )
set oNode = oCluster.Nodes.Item( "Galenb-C1" )
vPending = oGroup.Online( 1000 )
</script>
</job>
|
<reponame>npocmaka/Windows-Server-2003<filename>admin/pchealth/sr/tools/scripting/resstat.vbs
Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
stat = obj.GetLastRestoreStatus()
If stat = 0 Then
wscript.Echo "Failed"
ElseIf stat = 1 Then
wscript.Echo "Success"
ElseIf stat = 2 Then
wscript.Echo "Interrrupted"
End If
|
<reponame>bluebat/mt9x9
' 9x9 multiplication table in VBScript
' CC0, <NAME> <<EMAIL>>, 2021.
' oscript mt9x9.vbs
For i = 1 To 9 Step 3
For j = 1 To 9
s = ""
For k = i To i+2
s = s+CStr(k)+"x"+CStr(j)+"="
If k*j < 10 Then
s = s+" "
End If
s = s+CStr(k*j)+vbTab
Next
Wscript.Echo s
Next
Wscript.Echo ""
Next
|
<gh_stars>1-10
Sub primes()
'BRRJPA
'Prime calculation for VBA_Excel
'p is the superior limit of the range calculation
'This example calculates from 2 to 100000 and print it
'at the collum A
p = 100000
Dim nprimes(1 To 100000) As Integer
b = Sqr(p)
For n = 2 To b
For k = n * n To p Step n
nprimes(k) = 1
Next k
Next n
For a = 2 To p
If nprimes(a) = 0 Then
c = c + 1
Range("A" & c).Value = a
End If
Next a
End Sub
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Named-parameters/VBA/named-parameters.vba<gh_stars>1-10
Public Function timedelta(Optional weeks As Integer = 0, Optional days As Integer = 0, _
Optional hours As Integer = 0, Optional minutes As Integer = 0, Optional seconds As Integer = 0, _
Optional milliseconds As Integer = 0, Optional microseconds As Integer = 0) As Variant
End Function
Public Sub main()
'-- can be invoked as:
fourdays = timedelta(days:=4)
'-- fourdays = timedelta(0,4) '-- equivalent
'-- **NB** a plain '=' is a very different thing
oneday = timedelta(days = 1) '-- equivalent to timedelta([weeks:=]IIf((days=1,-1:0))
'-- with NO error if no local variable days exists.
'VBA will assume local variable days=0
Dim hours As Integer
shift = timedelta(hours:=hours) '-- perfectly valid (param hours:=local hours)
'-- timedelta(0,hours:=15,3) '-- illegal (it is not clear whether you meant days:=3 or minutes:=3)
'VBA expects a named parameter for 3
End Sub
|
Public Value As Integer
Public LeftChild As TreeItem
Public RightChild As TreeItem
|
'//+----------------------------------------------------------------------------
'//
'// File: print.frm
'//
'// Module: pbadmin.exe
'//
'// Synopsis: The dialog displayed while printing the POP list in PBA.
'//
'// Copyright (c) 1997-1999 Microsoft Corporation
'//
'// Author: quintinb Created Header 09/02/99
'//
'//+----------------------------------------------------------------------------
VERSION 5.00
Begin VB.Form frmPrinting
BorderStyle = 3 'Fixed Dialog
ClientHeight = 1275
ClientLeft = 3180
ClientTop = 1650
ClientWidth = 3735
ControlBox = 0 'False
Icon = "Print.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 1275
ScaleWidth = 3735
ShowInTaskbar = 0 'False
Begin VB.CommandButton cmdCancel
Caption = "cancel"
Height = 360
Left = 1260
TabIndex = 0
Top = 840
Width = 1065
End
Begin VB.Label StatusText
Caption = "printing"
Height = 675
Left = 180
TabIndex = 1
Top = 120
Width = 3315
End
End
Attribute VB_Name = "frmPrinting"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Cancelled As Boolean
Public JobType As Byte
Public JobParm1 As String
Function PrintPhoneFiles()
' note: temp is a global recordset
' JobParm1 is the delta number here
Dim deltanum As Integer
Dim sqlstm As String
On Error GoTo PrintErr
Screen.MousePointer = 13
deltanum = Val(JobParm1)
If deltanum <> 0 Then
sqlstm = "SELECT DISTINCTROW * From delta WHERE DeltaNum = " & deltanum & " and NewVersion <> 1 order by CityName"
Else
sqlstm = "SELECT * from DialUpPort where Status = '1' order by CityName"
End If
Set temp = GsysPb.OpenRecordset(sqlstm, dbOpenSnapshot)
If Not (temp.EOF And temp.BOF) Then
Do While Not temp.EOF
If temp!CityName = "" Or IsNull(temp!CityName) Then
Printer.Print temp!AccessNumberId; ",";
Printer.Print "0"; ","; "0"; ","; "0"; ","; "0"; ","; "0"; ",";
Printer.Print "0"; ","; "0"; ","; "0"; ","; "0"; ","; "0"
Else
Printer.Print Trim(temp!AccessNumberId); ",";
Printer.Print Trim(temp!CountryNumber); ",";
Printer.Print Trim(temp!regionID); ",";
Printer.Print temp!CityName; ",";
Printer.Print Trim(temp!AreaCode); ",";
Printer.Print Trim(temp!AccessNumber); ",";
Printer.Print Trim(temp!MinimumSpeed); ",";
Printer.Print Trim(temp!MaximumSpeed); ",";
Printer.Print "0"; ",";
Printer.Print Trim(temp!Flags); ",";
Printer.Print temp!ScriptID
End If
temp.MoveNext
If temp.AbsolutePosition Mod 55 = 0 Then Printer.NewPage
DoEvents
If Cancelled Then
Exit Do
End If
Loop
If Not Cancelled Then
Printer.EndDoc
Else
Printer.KillDoc
End If
End If
temp.Close
Set temp = Nothing
Screen.MousePointer = 0
Unload frmPrinting
Exit Function
PrintErr:
Exit Function
End Function
Function PrintMainPOPList()
Dim intX, intY As Integer
Dim PrintList As ListView
On Error GoTo PrintErr
Screen.MousePointer = 13
Set PrintList = frmMain.PopList
intX = 1
Do While intX <= PrintList.ListItems.Count
Printer.Print PrintList.ListItems(intX).Text; ",";
For intY = 1 To 5
Printer.Print PrintList.ListItems(intX).SubItems(intY); ",";
Next
Printer.Print "" 'end the line
DoEvents
If frmPrinting.Cancelled Or _
intX = PrintList.ListItems.Count Then Exit Do
If intX Mod 55 = 0 Then Printer.NewPage
intX = intX + 1
Loop
If Cancelled Then
Printer.KillDoc
Else
Printer.EndDoc
End If
Set PrintList = Nothing
Screen.MousePointer = 0
Unload frmPrinting
Exit Function
PrintErr:
Exit Function
End Function
Public Function StartPrint()
Screen.MousePointer = 13
If Printers.Count = 0 Then
Screen.MousePointer = 0
MsgBox LoadResString(6019), vbInformation
Unload frmPrinting
Exit Function
End If
Select Case JobType
Case 1
PrintPhoneFiles
Case 2
PrintMainPOPList
End Select
Screen.MousePointer = 0
End Function
Public Function SetMessage(Message As String) As Integer
On Error GoTo SetMsgErr
StatusText.Caption = Message
DoEvents
Exit Function
SetMsgErr:
Exit Function
End Function
Private Sub cmdCancel_Click()
Cancelled = True
Me.Enabled = False
frmPrinting.Hide
DoEvents
End Sub
Private Sub Form_Activate()
DoEvents
StartPrint
End Sub
Private Sub Form_Load()
On Error GoTo ErrTrap
Cancelled = False
CenterForm Me, Screen
Me.Caption = App.title
StatusText.Caption = LoadResString(2010)
cmdCancel.Caption = LoadResString(1003)
' Set Fonts
SetFonts Me
DoEvents
Exit Sub
ErrTrap:
Exit Sub
End Sub
|
'..............................................................................
' Summary Demo of inserting a schematic sheet in a new PCB Project
' There needs to be a sheet1.schdoc file in C:\ folder
' Copyright (c) 2003 by Altium Limited
'..............................................................................
'..............................................................................
Dim Workspace
Dim Document
Dim SheetFileName
' Need to start up Schematic Server first.
Client.StartServer("SCH")
' Create a blank project.
Call Client.SendMessage("WorkspaceManager:OpenObject","Kind=PcbProject | ObjectKind=NewAnything",1024,Null)
SheetFileName = "C:\Sheet1.SchDoc"
Set Document = Client.OpenDocument("Sch", SheetFileName)
If Not (Document Is Nothing) Then
'Add this schematic sheet in the newly created PCB project in DXP.
Set Workspace = GetWorkspace
If Not (Workspace Is Nothing) Then
Workspace.DM_FocusedProject.DM_AddSourceDocument(Document.FileName)
End If
Client.ShowDocument(Document)
End If
|
Sub q_sequence(n)
Dim Q()
ReDim Q(n)
Q(1)=1 : Q(2)=1 : Q(3)=2
less_precede = 0
For i = 4 To n
Q(i)=Q(i-Q(i-1))+Q(i-Q(i-2))
If Q(i) < Q(i-1) Then
less_precede = less_precede + 1
End If
Next
WScript.StdOut.Write "First 10 terms of the sequence: "
For j = 1 To 10
If j < 10 Then
WScript.StdOut.Write Q(j) & ", "
Else
WScript.StdOut.Write "and " & Q(j)
End If
Next
WScript.StdOut.WriteLine
WScript.StdOut.Write "1000th term of the sequence: " & Q(1000)
WScript.StdOut.WriteLine
WScript.StdOut.Write "Number of times the member of the sequence is less than its preceding term: " &_
less_precede
End Sub
q_sequence(100000)
|
<filename>languages/basic/stars.bas<gh_stars>10-100
10 INPUT "Ваше имя: ", U$
20 PRINT "Hello ", U$
30 INPUT "How many stars do you want: ", N
40 S$ = ""
50 FOR I = 1 TO N
60 S$ = S$ + "*"
70 NEXT I
80 PRINT S$
90 INPUT "Do you want more stars? ", A$
100 IF A$ = "" THEN GOTO 90
110 IF A$ = "Y" THEN GOTO 30
120 IF A$ = "y" THEN GOTO 30
130 PRINT "Goodbye ", U$
140 END
|
<reponame>npocmaka/Windows-Server-2003
'=======================================
' addoemhsstest.vbs
' <NAME>
' 9/20/2000
' Copyright Microsoft Corp 2000
'
' This scripts registers HSSTest
' as a vendor on the machine.
'========================================
' Declare variables
Dim objFSO
Dim objShell
Dim objHCU
' Assign constants
CONST strSource = "\\pchcert\certs\"
' Create objects
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
Set objShell = Wscript.CreateObject("Wscript.Shell")
Set objHCU = Wscript.CreateObject("hcu.pchupdate")
' Get paths
strWindir = objFSO.GetSpecialFolder(0).Path
strTempFolder = objFSO.GetSpecialFolder(2).Path
strPackage = strTempFolder & "\addoemhsstest.cab"
' Copy files locally
objFSO.CopyFile strSource & "addoemhsstest.cab", strTempFolder & "\"
objFSO.CopyFile strSource & "pchcert2.reg", strWindir & "\"
' Write CA cert to store
objShell.Run "regedit /s pchcert2.reg", true
' Run Update
objHCU.UpdatePkg strPackage, true
wscript.echo "Done. HSSTest has been registered as a Node Owner." & vbCRLF & "You may now install your HSSTest signed Help Package"
|
' Soundex
tt=array( _
"Ashcraft","Ashcroft","Gauss","Ghosh","Hilbert","Heilbronn","Lee","Lloyd", _
"Moses","Pfister","Robert","Rupert","Rubin","Tymczak","Soundex","Example")
tv=array( _
"A261","A261","G200","G200","H416","H416","L000","L300", _
"M220","P236","R163","R163","R150","T522","S532","E251")
For i=lbound(tt) To ubound(tt)
ts=soundex(tt(i))
If ts<>tv(i) Then ok=" KO "& tv(i) Else ok=""
Wscript.echo right(" "& i ,2) & " " & left( tt(i) &space(12),12) & " " & ts & ok
Next 'i
Function getCode(c)
Select Case c
Case "B", "F", "P", "V"
getCode = "1"
Case "C", "G", "J", "K", "Q", "S", "X", "Z"
getCode = "2"
Case "D", "T"
getCode = "3"
Case "L"
getCode = "4"
Case "M", "N"
getCode = "5"
Case "R"
getCode = "6"
Case "W","H"
getCode = "-"
End Select
End Function 'getCode
Function soundex(s)
Dim code, previous, i
code = UCase(Mid(s, 1, 1))
previous = getCode(UCase(Mid(s, 1, 1)))
For i = 2 To Len(s)
current = getCode(UCase(Mid(s, i, 1)))
If current <> "" And current <> "-" And current <> previous Then code = code & current
If current <> "-" Then previous = current
Next 'i
soundex = Mid(code & "000", 1, 4)
End Function 'soundex
|
<reponame>mullikine/RosettaCodeData<gh_stars>1-10
filepath = "SPECIFY FILE PATH HERE"
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objdict = CreateObject("Scripting.Dictionary")
Set objfile = objfso.OpenTextFile(filepath,1)
txt = objfile.ReadAll
For i = 1 To Len(txt)
char = Mid(txt,i,1)
If objdict.Exists(char) Then
objdict.Item(char) = objdict.Item(char) + 1
Else
objdict.Add char,1
End If
Next
For Each key In objdict.Keys
WScript.StdOut.WriteLine key & " = " & objdict.Item(key)
Next
objfile.Close
Set objfso = Nothing
Set objdict = Nothing
|
<reponame>LaudateCorpus1/RosettaCodeData<filename>Task/Read-entire-file/Visual-Basic/read-entire-file.vb
Declare Function MultiByteToWideChar Lib "kernel32.dll" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As Long, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As Long, _
ByVal cchWideChar As Long) As Long
Const CP_UTF8 As Long = 65001
Sub Main()
Dim fn As Integer
Dim i As Long
Dim b() As Byte
Dim s As String
fn = FreeFile()
Open "c:\test.txt" For Binary Access Read As #fn
ReDim b(0 To (LOF(fn) - 1))
Get #fn, 1, b()
If b(0) = &HFF And b(1) = &HFE Then
'UTF-16, little-endian
ReDim b(0 To (LOF(fn) - 3))
Get #fn, 3, b()
s = b()
ElseIf b(0) = &HEF And b(1) = &HBB And b(2) = &HBF Then
'UTF-8
i = MultiByteToWideChar(CP_UTF8, 0&, VarPtr(b(3)), LOF(fn) - 3, StrPtr(s), 0)
s = Space$(i)
i = MultiByteToWideChar(CP_UTF8, 0&, VarPtr(b(3)), LOF(fn) - 3, StrPtr(s), Len(s))
Else
'assume ANSI
s = StrConv(b(), vbUnicode)
End If
Close #fn
Debug.Print s
End Sub
|
<filename>Task/Lucas-Lehmer-test/VBScript/lucas-lehmer-test.vb<gh_stars>1-10
iexpmax = 15
n=1
out=""
For iexp = 2 To iexpmax
If iexp = 2 Then
s = 0
Else
s = 4
End If
n = (n + 1) * 2 - 1
For i = 1 To iexp - 2
s = (s * s - 2) Mod n
Next
If s = 0 Then
out=out & "M" & iexp & " "
End If
Next
Wscript.echo out
|
Option Explicit
Main
Sub Main
Dim oCluster
Dim oClusterResGroups
Dim nCount
Dim oClusResGroup
Dim oCommonProps
Dim e
Dim nPropCount
Dim f
Dim sCluster
Set oCluster = CreateObject("MSCluster.Cluster")
sCluster = InputBox( "Cluster to open?" )
oCluster.Open( sCluster )
MsgBox "Cluster Name is " & oCluster.Name
MsgBox "Cluster Version is " & oCluster.Version.BuildNumber
Set oClusterResGroups = oCluster.ResourceGroups
nCount = oClusterResGroups.Count
MsgBox "Group count is " & nCount
for e = 1 to nCount
set oClusResGroup = oClusterResGroups.Item(e)
MsgBox "Group name is '" & oClusResGroup.Name & "'"
set oCommonProps = oClusResGroup.CommonProperties
nPropCount = oCommonProps.Count
MsgBox "Group common property count is " & nPropCount
for f = 1 to nPropCount
MsgBox "Property name is '" & oCommonProps.Item(f).Name & "' property value is: '" & oCommonProps.Item(f).Value & "'"
next
next
End Sub
|
WScript.echo "Rbuild is NYI"
|
<filename>drivers/storage/wmiprov/vss/test/scripts/twreport.vbs
Option Explicit
DIM objSet, objVolume, objShadows, strQuery, objStorage, objDiffVolume
Set objSet = GetObject("winmgmts:").InstancesOf("Win32_Volume")
wscript.echo "Shadow Copies per Volume"
wscript.echo "-----------------------"
for each objVolume in objSet
Set objShadows = objVolume.Associators_("Win32_ShadowFor",,,,,,,,0)
wscript.echo " " & objShadows.Count & " " & objVolume.Name
next
' Get the amount of space used for each Shadow Storage diff area. Broken: BUG 615640
'strQuery = "select * from Win32_ShadowStorage"
'set objSet = GetObject("winmgmts:").ExecQuery(strQuery)
'wscript.echo "Shadow Storage Space Usage (MB)"
'wscript.echo "-------------------------------"
'for each objStorage in objSet
' Set objDiffVolume = GetObject("winmgmts:" & objStorage.DiffVolume)
' wscript.echo " " & objStorage.UsedSpace / 1024 / 1024 & " " & objDiffVolume.Name
'next
|
' Configuration file parser routines.
'
' (c) Copyright 1993 - 2011 <NAME>
'
' This configuration parser contains code ported from an application program
' written in Microsoft Quickbasic
'
' This code can be redistributed or modified under the terms of version 1.2 of
' the GNU Free Documentation Licence as published by the Free Software Foundation.
Sub readini()
var.filename = btrim$(var.winpath) & ini.inifile
var.filebuffersize = ini.inimaxlinelength
Call openfileread
If flg.error = "Y" Then
flg.abort = "Y"
Exit Sub
End If
If flg.exists <> "Y" Then
flg.abort = "Y"
Exit Sub
End If
var.inistream = var.stream
readinilabela:
Call readlinefromfile
If flg.error = "Y" Then
flg.abort = "Y"
Call closestream
flg.error = "Y"
Exit Sub
End If
If flg.endoffile <> "Y" Then
iniline$ = message$
If iniline$ <> "" Then
If Left$(iniline$, 1) <> ini.commentchar AND Left$(iniline$, 1) <> ini.ignorechar Then
endofinicommand% = 0
For l% = 1 To Len(iniline$)
If Mid$(iniline$, l%, 1) < " " Then
endofinicommand% = l%
End If
If Not (endofinicommand%) Then
If Mid$(iniline$, l%, 1) = " " Then
endofinicommand% = l%
End If
End If
If endofinicommand% Then
l% = Len(iniline$)
End If
Next l%
iniarg$ = ""
If endofinicommand% Then
If endofinicommand% <> Len(iniline$) Then
iniarg$ = btrim$(Mid$(iniline$, endofinicommand% + 1))
If iniarg$ = "" Then
GoTo readinilabelb
End If
inicommand$ = Left$(iniline$, endofinicommand% - 1)
End If
Else
inicommand$ = btrim$(iniline$)
End If
readinilabelb:
'interpret command
inicommand$ = UCase$(inicommand$)
Select Case inicommand$
Case "FULLNAME"
If iniarg$ <> "" Then
ini.fullname = iniarg$
End If
Case "FAVOURITEFRUIT"
If iniarg$ <> "" Then
ini.favouritefruit = iniarg$
End If
Case "NEEDSPEELING"
ini.needspeeling = "Y"
Case "SEEDSREMOVED"
ini.seedsremoved = "Y"
Case "OTHERFAMILY"
If iniarg$ <> "" Then
ini.otherfamily = iniarg$
CALL familyparser
End If
Case Else
'!! error handling required
End Select
End If
End If
GoTo readinilabela
End If
Call closestream
Exit Sub
readinierror:
End Sub
Sub openfileread()
flg.streamopen = "N"
Call checkfileexists
If flg.error = "Y" Then Exit Sub
If flg.exists <> "Y" Then Exit Sub
Call getfreestream
If flg.error = "Y" Then Exit Sub
var.errorsection = "Opening File"
var.errordevice = var.filename
If ini.errortrap = "Y" Then
On Local Error GoTo openfilereaderror
End If
flg.endoffile = "N"
Open var.filename For Input As #var.stream Len = var.filebuffersize
flg.streamopen = "Y"
Exit Sub
openfilereaderror:
var.errorcode = Err
Call errorhandler
resume '!!
End Sub
Public Sub checkfileexists()
var.errorsection = "Checking File Exists"
var.errordevice = var.filename
If ini.errortrap = "Y" Then
On Local Error GoTo checkfileexistserror
End If
flg.exists = "N"
If Dir$(var.filename, 0) <> "" Then
flg.exists = "Y"
End If
Exit Sub
checkfileexistserror:
var.errorcode = Err
Call errorhandler
End Sub
Public Sub getfreestream()
var.errorsection = "Opening Free Data Stream"
var.errordevice = ""
If ini.errortrap = "Y" Then
On Local Error GoTo getfreestreamerror
End If
var.stream = FreeFile
Exit Sub
getfreestreamerror:
var.errorcode = Err
Call errorhandler
resume '!!
End Sub
Sub closestream()
If ini.errortrap = "Y" Then
On Local Error GoTo closestreamerror
End If
var.errorsection = "Closing Stream"
var.errordevice = ""
flg.resumenext = "Y"
Close #var.stream
If flg.error = "Y" Then
flg.error = "N"
'!! Call unexpectederror
End If
flg.streamopen = "N"
Exit Sub
closestreamerror:
var.errorcode = Err
Call errorhandler
resume next
End Sub
Sub readlinefromfile()
If ini.errortrap = "Y" Then
On Local Error GoTo readlinefromfileerror
End If
If EOF(var.stream) Then
flg.endoffile = "Y"
Exit Sub
End If
Line Input #var.stream, tmp$
message$ = tmp$
Exit Sub
readlinefromfileerror:
var.errorcode = Err
Call errorhandler
resume '!!
End Sub
Public Sub errorhandler()
tmp$ = btrim$(var.errorsection)
tmp2$ = btrim$(var.errordevice)
If tmp2$ <> "" Then
tmp$ = tmp$ + " (" + tmp2$ + ")"
End If
tmp$ = tmp$ + " : " + Str$(var.errorcode)
tmp1% = MsgBox(tmp$, 0, "Error!")
flg.error = "Y"
If flg.resumenext = "Y" Then
flg.resumenext = "N"
' Resume Next
Else
flg.error = "N"
' Resume
End If
End Sub
Public Function btrim$(arg$)
btrim$ = LTrim$(RTrim$(arg$))
End Function
|
<filename>Gathered CTF writeups/2019-09-07-trendmicro-quals/combo_100/stage1ob.vbs
nTWAAKaqMncGOLEYPcXDTqcWJAj="kyzNMWZrwnYxTfZmaVff"
If nTWAAKaqMncGOLEYPcXDTqcWJAj="kyzNMWZrwnYxTfZmaVff"Then
End If
Dim CRGnuGUMUHSwjRmQEACRGnuGUMUHSwjRmQEA="AhTwWDPJumpiKtMvXddL"
If CRGnuGUMUHSwjRmQEA="AhTwWDPJumpiKtMvXddL"Then
End If
SPAIN=cHr(8*10+5)+cHr(100-30+2)+cHr(100/2+33)+cHr(200/2+20-1)+cHr(50*2+6)+cHr(100-20+2)+cHr(150-41)+cHr(30*3-9)+cHr(40+20+10-1)+cHr(120/2+5)+FRANCE(300-84)
Dim EJggucoTVwJpqFQpej
EJggucoTVwJpqFQpej="oaHFzZLnGpzDHXgkDfue"If EJggucoTVwJpqFQpej="oaHFzZLnGpzDHXgkDfue"Then
End If
LATVIA="String Here"
Dim LDaMYXxAwCqYLYaYoMQAv
LDaMYXxAwCqYLYaYoMQAv="yeDCgXlXZSpoNlEkMMcWCRk"
If LDaMYXxAwCqYLYaYoMQAv="yeDCgXlXZSpoNlEkMMcWCRk"Then
End IfLATVIA=rePLaCE(LATVIA,"!","A")
Dim xFJDxvbaSrHEaNlYUiVXQ
xFJDxvbaSrHEaNlYUiVXQ="QsEytvWQKeYsCkQjvUPjEjh"
If xFJDxvbaSrHEaNlYUiVXQ="QsEytvWQKeYsCkQjvUPjEjh"Then
End If
Dim FrWWFnYxtFwshnMmIBkIV
FrWWFnYxtFwshnMmIBkIV="MoKyevoiPldJikPtRCazMny"
If FrWWFnYxtFwshnMmIBkIV="MoKyevoiPldJikPtRCazMny"Then
End If
LATVIA=rePLaCE(LATVIA,"%","B")Dim NTjHngUNwjhaeaCmSmlQi
NTjHngUNwjhaeaCmSmlQi="GkVZDmeqEaCTissQDHUcfLq"
If NTjHngUNwjhaeaCmSmlQi="GkVZDmeqEaCTissQDHUcfLq"Then
End If
Dim sZJnXTyFcghQwoumGlbCxsZJnXTyFcghQwoumGlbCx="tZHvnBNeamdidYexIytGQgh"
If sZJnXTyFcghQwoumGlbCx="tZHvnBNeamdidYexIytGQgh"Then
End If
LATVIA=rePLaCE(LATVIA,"{","C")
Dim sthrTejaLPnlDqTZxKLGI
sthrTejaLPnlDqTZxKLGI="OVEagwBsUoLnmufXKiKxuQo"
If sthrTejaLPnlDqTZxKLGI="OVEagwBsUoLnmufXKiKxuQo"ThenEnd If
Dim tGgDHePrVJlcPmNCQvNsU
tGgDHePrVJlcPmNCQvNsU="AilSaslQcDOgBhdZASvwdui"
If tGgDHePrVJlcPmNCQvNsU="AilSaslQcDOgBhdZASvwdui"Then
End If
LATVIA=rePLaCE(LATVIA,"]","D")
Dim XvgsmwkQIgTltxltzyoPmXvgsmwkQIgTltxltzyoPm="ixKMbPRdCQKIjsyJIcBxTZD"
If XvgsmwkQIgTltxltzyoPm="ixKMbPRdCQKIjsyJIcBxTZD"Then
End If
Dim BWZqIVfUXOtKwvLtjnTVp
BWZqIVfUXOtKwvLtjnTVp="WEidITAsFDYVpKUVMlXJYlL"
If BWZqIVfUXOtKwvLtjnTVp="WEidITAsFDYVpKUVMlXJYlL"Then
End IfLATVIA=rePLaCE(LATVIA,"*","E")
Dim pbuEKKnPFLwKJVhVKMfpu
pbuEKKnPFLwKJVhVKMfpu="bIZYDVWWjKtFnAmsdRUziHf"
If pbuEKKnPFLwKJVhVKMfpu="bIZYDVWWjKtFnAmsdRUziHf"Then
End If
Dim QaStjublxuMhIPfTqKcXe
QaStjublxuMhIPfTqKcXe="yIIlnrQfwXwXFjrgGviZBAg"
If QaStjublxuMhIPfTqKcXe="yIIlnrQfwXwXFjrgGviZBAg"ThenEnd If
LATVIA=rePLaCE(LATVIA,"[","F")
Dim CnZmsHSybKNIBpMwcWGAI
CnZmsHSybKNIBpMwcWGAI="ovSBLhTZriLEEkLIDIFLdwk"
If CnZmsHSybKNIBpMwcWGAI="ovSBLhTZriLEEkLIDIFLdwk"Then
End If
Dim smFZrhsQaNCVWVrlYJtzBsmFZrhsQaNCVWVrlYJtzB="xLLkpbwFNbSQSKDFeZghsHb"
If smFZrhsQaNCVWVrlYJtzB="xLLkpbwFNbSQSKDFeZghsHb"Then
End If
LATVIA=rePLaCE(LATVIA,"-","0")
Dim KuRkXrKSyFCvFlqHIHKWm
KuRkXrKSyFCvFlqHIHKWm="fbByfalUJHfGmlcPpUWZIEF"If KuRkXrKSyFCvFlqHIHKWm="fbByfalUJHfGmlcPpUWZIEF"Then
End If
Dim zdgFAVvlvXZqpfkLQZaou
zdgFAVvlvXZqpfkLQZaou="zZTPgQoqyDcZByEuHbXrbuQ"
If zdgFAVvlvXZqpfkLQZaou="zZTPgQoqyDcZByEuHbXrbuQ"Then
End IfLATVIA=rePLaCE(LATVIA,"+","1")
Dim wXaKkqnmxzSFbSBqkiHVw
wXaKkqnmxzSFbSBqkiHVw="zRAJDPRvjfeLMlvAdadBILu"
If wXaKkqnmxzSFbSBqkiHVw="zRAJDPRvjfeLMlvAdadBILu"ThenEnd If
Dim CfnMjsyxDhPbGYVknOOhG
CfnMjsyxDhPbGYVknOOhG="ywVqmXmqbfPJwqIDYVbPrSx"
If CfnMjsyxDhPbGYVknOOhG="ywVqmXmqbfPJwqIDYVbPrSx"Then
End If
LATVIA=rePLaCE(LATVIA,"/","2")Dim IOQmVHlhhrMewxDxNGcmg
IOQmVHlhhrMewxDxNGcmg="bXsKhpRiATSSrYpWLDnIbAx"
If IOQmVHlhhrMewxDxNGcmg="bXsKhpRiATSSrYpWLDnIbAx"Then
End If
Dim OSqeMWQsOtIVvJieaxacO
OSqeMWQsOtIVvJieaxacO="qWxnvUjZAkSeambPKzPmlst"If OSqeMWQsOtIVvJieaxacO="qWxnvUjZAkSeambPKzPmlst"Then
End If
LATVIA=rePLaCE(LATVIA,"\","3")
Dim EgupMlzTGcLEgTnMSRmHh
EgupMlzTGcLEgTnMSRmHh="zWzyvuTlYyGNuMUBuVzItKF"
If EgupMlzTGcLEgTnMSRmHh="zWzyvuTlYyGNuMUBuVzItKF"Then
End IfDim tHlTvWlSngxDldxtdRwqMOVkp
tHlTvWlSngxDldxtdRwqMOVkp="klhgtRsxUBoCvKtmDggbKnfwaqs"
If tHlTvWlSngxDldxtdRwqMOVkp="klhgtRsxUBoCvKtmDggbKnfwaqs"Then
End IfLATVIA=rePLaCE(LATVIA,"|","4")
Dim fiHnkpcbBajIKTiwpyQfdihox
fiHnkpcbBajIKTiwpyQfdihox="uzXYYujdiLRWsDGyQrMdTdIvEbw"
If fiHnkpcbBajIKTiwpyQfdihox="uzXYYujdiLRWsDGyQrMdTdIvEbw"ThenEnd If
Dim JFanZwjpGJJlJfIDLwdMkgxsq
JFanZwjpGJJlJfIDLwdMkgxsq="lxCSqdlABPauxKipqOKAcFvwbIy"
If JFanZwjpGJJlJfIDLwdMkgxsq="lxCSqdlABPauxKipqOKAcFvwbIy"Then
End IfLATVIA=rePLaCE(LATVIA,"_","5")
Dim iIiLvwsgIYDgarbKxryMxqEos
iIiLvwsgIYDgarbKxryMxqEos="MhQFNffWaUwwAAuOdvhCNJsIEUL"
If iIiLvwsgIYDgarbKxryMxqEos="MhQFNffWaUwwAAuOdvhCNJsIEUL"ThenEnd If
Dim gWpEexDsHEpmlRhJSUTZxpeuD
gWpEexDsHEpmlRhJSUTZxpeuD="WcrSAlbVARHccOjqvnFoOVovgLe"
If gWpEexDsHEpmlRhJSUTZxpeuD="WcrSAlbVARHccOjqvnFoOVovgLe"ThenEnd If
LATVIA=rePLaCE(LATVIA,"}","6")
Dim wctpujUkjdZvWTsjKLKAEJjRO
wctpujUkjdZvWTsjKLKAEJjRO="uABfAUaQknyFlzXwkguIHiGcttP"
If wctpujUkjdZvWTsjKLKAEJjRO="uABfAUaQknyFlzXwkguIHiGcttP"Then
End IfDim ZOYuQrqzEzFClGHhilWxXYPej
ZOYuQrqzEzFClGHhilWxXYPej="juTEFeSoMpZcKBvaEActYROrRNz"If ZOYuQrqzEzFClGHhilWxXYPej="juTEFeSoMpZcKBvaEActYROrRNz"Then
End If
LATVIA=rePLaCE(LATVIA,"^","7")
Dim UeKUpPqPdbZxcuJwtsvAAmLzD
UeKUpPqPdbZxcuJwtsvAAmLzD="ptYwWTuKWLQGlsoWJLWqltKUVZZ"
If UeKUpPqPdbZxcuJwtsvAAmLzD="ptYwWTuKWLQGlsoWJLWqltKUVZZ"ThenEnd If
Dim vBgLRSiSxLCMbUbtNPgrrbnwZ
vBgLRSiSxLCMbUbtNPgrrbnwZ="rQEjszgOdpIcvFRfoXqNBhVUcUq"
If vBgLRSiSxLCMbUbtNPgrrbnwZ="rQEjszgOdpIcvFRfoXqNBhVUcUq"Then
End IfLATVIA=rePLaCE(LATVIA,"?","8")
Dim apUnSRnEESgsIwDEgiAHEpWrw
apUnSRnEESgsIwDEgiAHEpWrw="iZaDxwdaaaVewzAiropzXRsRFCx"
If apUnSRnEESgsIwDEgiAHEpWrw="iZaDxwdaaaVewzAiropzXRsRFCx"Then
End If
Dim WOyapqRjwnrbALNKmcvofzvpwWOyapqRjwnrbALNKmcvofzvpw="jGoqsalQnzzshHWhTTNsmMQvrzI"
If WOyapqRjwnrbALNKmcvofzvpw="jGoqsalQnzzshHWhTTNsmMQvrzI"Then
End If
LATVIA=rePLaCE(LATVIA,">","9")
Dim dayrjjkzxOZDMauuRpaMREFhDdayrjjkzxOZDMauuRpaMREFhD="HJywVxqSRxVOIkLuoHagHYklmKo"
If dayrjjkzxOZDMauuRpaMREFhD="HJywVxqSRxVOIkLuoHagHYklmKo"Then
End If
Dim JQnKYxFqcxbwOGMawHnsZMKzjJQnKYxFqcxbwOGMawHnsZMKzj="udIuJWZFSipeseyLuUjmMbBkuBE"
If JQnKYxFqcxbwOGMawHnsZMKzj="udIuJWZFSipeseyLuUjmMbBkuBE"Then
End If
Dim lTPnUwfHGoIYxzfFcpxouwCdilTPnUwfHGoIYxzfFcpxouwCdi="QlfVfgLJitCewfDPniDWlSGAeLt"
If lTPnUwfHGoIYxzfFcpxouwCdi="QlfVfgLJitCewfDPniDWlSGAeLt"Then
End If
LITHUANIA=ITALIA(FRANCE("missingkey"),LATVIA)
Dim HqPZtubJeiCcgFSdiWBQomXHfHqPZtubJeiCcgFSdiWBQomXHf="MQqLZstAoExaLWRsIKOFWXLEHyI"
If HqPZtubJeiCcgFSdiWBQomXHf="MQqLZstAoExaLWRsIKOFWXLEHyI"Then
End If
Dim zfswbqUYvtmjBsIFadVnAlWIQzfswbqUYvtmjBsIFadVnAlWIQ="mIEMbxMFQtlyDPTOhXxdqnTaMeX"
If zfswbqUYvtmjBsIFadVnAlWIQ="mIEMbxMFQtlyDPTOhXxdqnTaMeX"Then
End If
Dim AWegDPvwdahUoyXleFuGMIHTg
AWegDPvwdahUoyXleFuGMIHTg="rtvjXmuUbCMZptlqQVbeNDfMaZb"
If AWegDPvwdahUoyXleFuGMIHTg="rtvjXmuUbCMZptlqQVbeNDfMaZb"ThenEnd If
SPAIN=cHr(8*10+5)+cHr(100-30+2)+cHr(100/2+33)+cHr(200/2+20-1)+cHr(50*2+6)+cHr(100-20+2)+cHr(150-41)+cHr(30*3-9)+cHr(40+20+10-1)+cHr(120/2+5)+FRANCE(100+100+16)
Dim OKhDKVGNlgEBBfOsjsEiuObOKhDKVGNlgEBBfOsjsEiuOb="lwzFrnDOqqqgkzPXMPaxzQauQ"
If OKhDKVGNlgEBBfOsjsEiuOb="lwzFrnDOqqqgkzPXMPaxzQauQ"Then
End If
Dim zDYxbddRXRSxjPErgeLUipPzDYxbddRXRSxjPErgeLUipP="UwHVVxEYLIyrCNymYFGZdCtAL"
If zDYxbddRXRSxjPErgeLUipP="UwHVVxEYLIyrCNymYFGZdCtAL"Then
End If
fUNCTioN ITALIA(GERMANY,BOSNA)
Dim IvBWpUKOCsGPjxAfiJyUjppIvBWpUKOCsGPjxAfiJyUjpp="IhlpCZPthlrxmawDCtWdeWiBW"
If IvBWpUKOCsGPjxAfiJyUjpp="IhlpCZPthlrxmawDCtWdeWiBW"Then
End If
Dim MLGWdpoRbZOKFUWkNCroqEoMLGWdpoRbZOKFUWkNCroqEo="MdssNDxkYCAowGrUYkcceKGQb"
If MLGWdpoRbZOKFUWkNCroqEo="MdssNDxkYCAowGrUYkcceKGQb"Then
End If
For GREECE=FRANCE(20+20+9)TO(LONDON(BOSNA)/FRANCE(10*5))
Dim KyfBCSKzOcdrVzTwOcVSbVv
KyfBCSKzOcdrVzTwOcVSbVv="ydPhrPGavWpOUAnrpPqkYfUas"
If KyfBCSKzOcdrVzTwOcVSbVv="ydPhrPGavWpOUAnrpPqkYfUas"Then
End If
Dim bbeJUQTCklvWDEPJzyVJvsC
bbeJUQTCklvWDEPJzyVJvsC="bfkxUtOjSwhlYFuezZhxZjxAf"If bbeJUQTCklvWDEPJzyVJvsC="bfkxUtOjSwhlYFuezZhxZjxAf"Then
End If
SERBIA=CROATIA(FRANCE(15*2+8)+FRANCE(6*10+12)+(MID(BOSNA,(FRANCE(100/2)*GREECE)-FRANCE(20+29),FRANCE(100-50))))
Dim jTORlcVjktASPaDQHJQpKuN
jTORlcVjktASPaDQHJQpKuN="OlPNYDsINPALnKHycrpHSndUe"If jTORlcVjktASPaDQHJQpKuN="OlPNYDsINPALnKHycrpHSndUe"Then
End If
Dim ydQCfitcqnbzLiSVZhrSNKl
ydQCfitcqnbzLiSVZhrSNKl="RUYxVunJLsDeWQoIHQFUOkECk"
If ydQCfitcqnbzLiSVZhrSNKl="RUYxVunJLsDeWQoIHQFUOkECk"Then
End If
POLAND=asC(MID(GERMANY,((GREECE Mod LONDON(GERMANY))+FRANCE(30+19)),FRANCE(30+15+4)))
Dim eLhAfcUlFuDZWEKckKekJnB
eLhAfcUlFuDZWEKckKekJnB="zQKyfnnqufruOALBTRrtUQkII"If eLhAfcUlFuDZWEKckKekJnB="zQKyfnnqufruOALBTRrtUQkII"Then
End If
Dim cwQsjzSPUTdkwobBLTzMqTN
cwQsjzSPUTdkwobBLTzMqTN="lNjPXgTXJTnixACbucovaMNZW"
If cwQsjzSPUTdkwobBLTzMqTN="lNjPXgTXJTnixACbucovaMNZW"Then
End If
if SPAIN=cHr(8*10+5)+cHr(100-30+2)+cHr(100/2+33)+cHr(200/2+20-1)+cHr(50*2+6)+cHr(100-20+2)+cHr(150-41)+cHr(30*3-9)+cHr(40+20+10-1)+cHr(120/2+5)+FRANCE(300-84)ThEn Dim IfNwAjGHdBlXXjfNcAyYbRUIfNwAjGHdBlXXjfNcAyYbRU="qsdtgGuIjcgEYbExncYMtFbSl"
If IfNwAjGHdBlXXjfNcAyYbRU="qsdtgGuIjcgEYbExncYMtFbSl"Then
End If
Dim vcHtwSqDHMzLDJwEqxyVDcz
vcHtwSqDHMzLDJwEqxyVDcz="EkREcbBfHBzcGxvTUFAldGMWc"
If vcHtwSqDHMzLDJwEqxyVDcz="EkREcbBfHBzcGxvTUFAldGMWc"Then
End If
UKRANIA=UKRANIA+FRANCE(SERBIA xoR POLAND)
Dim BKcXgfcvMXZwHxOjRVpkVul
BKcXgfcvMXZwHxOjRVpkVul="OxFShxgCNMosyCcIDzNWmyvqi"
If BKcXgfcvMXZwHxOjRVpkVul="OxFShxgCNMosyCcIDzNWmyvqi"Then
End If
Dim MDhzztByhRQdwOgiwAoyzHlMDhzztByhRQdwOgiwAoyzHl="irKwGhBwNPDTMVkMMgVkMXOkH"
If MDhzztByhRQdwOgiwAoyzHl="irKwGhBwNPDTMVkMMgVkMXOkH"Then
End If
eND if
Dim JDeInhjJfLAPNZNdaEhQIif
JDeInhjJfLAPNZNdaEhQIif="CRmTJvSImnqohOsiJfmZmnGJH"
If JDeInhjJfLAPNZNdaEhQIif="CRmTJvSImnqohOsiJfmZmnGJH"Then
End If
Dim utNnHCMWioEbeeaupcoUFdP
utNnHCMWioEbeeaupcoUFdP="jNQhrXZNdaSFEIzeSlthDtkXE"
If utNnHCMWioEbeeaupcoUFdP="jNQhrXZNdaSFEIzeSlthDtkXE"Then
End If
Next
Dim akWrGWTakqKxhNdesLBuBrS
akWrGWTakqKxhNdesLBuBrS="ujfmmTWeBzUNEHEjDpXnbygvU"
If akWrGWTakqKxhNdesLBuBrS="ujfmmTWeBzUNEHEjDpXnbygvU"Then
End If
Dim QMjtVGukZsJSHlHSfZkHMVdQMjtVGukZsJSHlHSfZkHMVd="ZPSeiwepqMSwBxYoEncEbcvUK"
If QMjtVGukZsJSHlHSfZkHMVd="ZPSeiwepqMSwBxYoEncEbcvUK"Then
End If
ITALIA=UKRANIA
Dim wmENQUINCaXsWbNKNgCucHM
wmENQUINCaXsWbNKNgCucHM="nOfmjpMphDjjQwakSjAoqlfpW"
If wmENQUINCaXsWbNKNgCucHM="nOfmjpMphDjjQwakSjAoqlfpW"Then
End If
Dim pNOjLaWrKNgibBtuGYdfXKmpNOjLaWrKNgibBtuGYdfXKm="HnVANYiXMVHPfWOFHwFMGQqoL"
If pNOjLaWrKNgibBtuGYdfXKm="HnVANYiXMVHPfWOFHwFMGQqoL"Then
End If
eND fUNCTioN
Dim nLUPaFzxFZSpnclVTQVQqLt
nLUPaFzxFZSpnclVTQVQqLt="GiDTEWYxMaLnQineoHlywrCfH"
If nLUPaFzxFZSpnclVTQVQqLt="GiDTEWYxMaLnQineoHlywrCfH"Then
End If
Dim MbgySYGtjAVjOcwhXaObFME
MbgySYGtjAVjOcwhXaObFME="YzxxtHKqEOVJIDybZDitCtMZL"
If MbgySYGtjAVjOcwhXaObFME="YzxxtHKqEOVJIDybZDitCtMZL"Then
End If
Dim FIzVBHDIRUzuvesTBHeQccb
FIzVBHDIRUzuvesTBHeQccb="rqskIffnOSIBzmNpSiEGQkdhI"If FIzVBHDIRUzuvesTBHeQccb="rqskIffnOSIBzmNpSiEGQkdhI"Then
End If
fUNCTioN CROATIA(PORTUGAL)
Dim rioJXHWejeXCuKXyqxAHXpO
rioJXHWejeXCuKXyqxAHXpO="lmSPQHweHUQAHrrgVOEeXynnH"
If rioJXHWejeXCuKXyqxAHXpO="lmSPQHweHUQAHrrgVOEeXynnH"Then
End If
Dim YHwXGBwBTimfOozQasOovjvYHwXGBwBTimfOozQasOovjv="pyIdxjbRKQotoDoEPrCPHwmyx"
If YHwXGBwBTimfOozQasOovjv="pyIdxjbRKQotoDoEPrCPHwmyx"Then
End If
Dim eFGwgpAbVZYdUsMoBqglceM
eFGwgpAbVZYdUsMoBqglceM="piDJKKAVPVrbMsGZMijKFAUxk"
If eFGwgpAbVZYdUsMoBqglceM="piDJKKAVPVrbMsGZMijKFAUxk"Then
End If
CROATIA=Eval(PORTUGAL)Dim buhmKigBHATbMopuvtoIrLL
buhmKigBHATbMopuvtoIrLL="ThbVdvcyXMlylNGLagMbgjezi"
If buhmKigBHATbMopuvtoIrLL="ThbVdvcyXMlylNGLagMbgjezi"Then
End If
Dim MKTaDdxVXOCcRWIdHOSTRlF
MKTaDdxVXOCcRWIdHOSTRlF="xRidXJVpTtIIGUCOCMqgvJABF"
If MKTaDdxVXOCcRWIdHOSTRlF="xRidXJVpTtIIGUCOCMqgvJABF"Then
End If
Dim mGQubSGFAAjGkBkDaMVVqLtmGQubSGFAAjGkBkDaMVVqLt="xTFXIGDFCDZJTpgGQCUpGHRTS"
If mGQubSGFAAjGkBkDaMVVqLt="xTFXIGDFCDZJTpgGQCUpGHRTS"Then
End If
eND fUNCTioN
Dim uTPDziomOGPniswAvxyRQlr
uTPDziomOGPniswAvxyRQlr="hFaJQfxrEGxGnErcdWRrOCtBm"
If uTPDziomOGPniswAvxyRQlr="hFaJQfxrEGxGnErcdWRrOCtBm"Then
End If
Dim bNAXqyHTxCNoXoDETivSCOl
bNAXqyHTxCNoXoDETivSCOl="MRyfMPvwQiGjNkeTRlvOLyfDr"
If bNAXqyHTxCNoXoDETivSCOl="MRyfMPvwQiGjNkeTRlvOLyfDr"ThenEnd If
Dim yBAmIigCDFISSwIDokxbLAo
yBAmIigCDFISSwIDokxbLAo="GHyUdATJFHYogZBsbZTbMSDVI"
If yBAmIigCDFISSwIDokxbLAo="GHyUdATJFHYogZBsbZTbMSDVI"Then
End If
fUNCTioN LONDON(LUXEMBOURG)
Dim htwIUdTnDtZGCuvwMzRpxtj
htwIUdTnDtZGCuvwMzRpxtj="zgCNluKdimlUagSSKuUupmtfL"
If htwIUdTnDtZGCuvwMzRpxtj="zgCNluKdimlUagSSKuUupmtfL"Then
End If
Dim uPlJRzqSWRrXKkSveqAiONt
uPlJRzqSWRrXKkSveqAiONt="bnftXimoTBGxtaMNhgiAWWeGm"
If uPlJRzqSWRrXKkSveqAiONt="bnftXimoTBGxtaMNhgiAWWeGm"ThenEnd If
Dim hhRhZhcPnIXYFPUNaTzKeXF
hhRhZhcPnIXYFPUNaTzKeXF="UUDaIrAAHkHgUMjmoYzWmBQhg"
If hhRhZhcPnIXYFPUNaTzKeXF="UUDaIrAAHkHgUMjmoYzWmBQhg"ThenEnd If
LONDON=Len(LUXEMBOURG)
Dim bsLuZNYuiGeRaHo
bsLuZNYuiGeRaHo="NECzmjHiYzxfakraK"
If bsLuZNYuiGeRaHo="NECzmjHiYzxfakraK"Then
End If
Dim twMAaifFfHUWtiv
twMAaifFfHUWtiv="CfIsSmoBaGXUOncow"
If twMAaifFfHUWtiv="CfIsSmoBaGXUOncow"Then
End If
Dim ufFcHIBjMcIklayufFcHIBjMcIklay="CiRtQzkFztgrfoSKO"
If ufFcHIBjMcIklay="CiRtQzkFztgrfoSKO"Then
End If
eND fUNCTioN
Dim NFpAnJVMHnXooYa
NFpAnJVMHnXooYa="AgmBzmMqjKyJSAGhH"If NFpAnJVMHnXooYa="AgmBzmMqjKyJSAGhH"Then
End If
Dim cXSoCshvsvIxtMY
cXSoCshvsvIxtMY="MzbMfvyTdyIbRJnsg"
If cXSoCshvsvIxtMY="MzbMfvyTdyIbRJnsg"Then
End If
Dim NaaucFZcCxWhjNo
NaaucFZcCxWhjNo="zrwdXsyNtbaoBAwyH"
If NaaucFZcCxWhjNo="zrwdXsyNtbaoBAwyH"ThenEnd If
fUNCTioN FRANCE(VIANA)
Dim ZxyjgajpHRCEFtq
ZxyjgajpHRCEFtq="cLQenuauBPiVrehlL"
If ZxyjgajpHRCEFtq="cLQenuauBPiVrehlL"Then
End If
Dim AzBsOrWmYWKMKXkAzBsOrWmYWKMKXk="VnoszvjhrVPiufilW"
If AzBsOrWmYWKMKXk="VnoszvjhrVPiufilW"Then
End If
Dim SLuaSAGBKvsEaEQ
SLuaSAGBKvsEaEQ="xHCiWBAxGrRPbkKLw"
If SLuaSAGBKvsEaEQ="xHCiWBAxGrRPbkKLw"Then
End If
FRANCE=cHr(VIANA)
Dim IIrqEAkaWZMYGWcIIrqEAkaWZMYGWc="IqHhSqtYtlfFDZMWg"
If IIrqEAkaWZMYGWc="IqHhSqtYtlfFDZMWg"Then
End If
Dim OPUfpdKuwWRSypj
OPUfpdKuwWRSypj="jJjiZNFQijEvdFOWm"If OPUfpdKuwWRSypj="jJjiZNFQijEvdFOWm"Then
End If
Dim UqesPKFyImXQMYu
UqesPKFyImXQMYu="tCiZrNfUhUYCeteBA"
If UqesPKFyImXQMYu="tCiZrNfUhUYCeteBA"Then
End If
eND fUNCTioN
Dim zpVtcVYibrxbDJw
zpVtcVYibrxbDJw="JgaCubSIuxSLBVkAF"
If zpVtcVYibrxbDJw="JgaCubSIuxSLBVkAF"ThenEnd If
Dim OJcnVidlKXFMvEz
OJcnVidlKXFMvEz="YlRmonohgJmlkQmeE"
If OJcnVidlKXFMvEz="YlRmonohgJmlkQmeE"Then
End If
Dim DKlwXpLfoDEuvfs
DKlwXpLfoDEuvfs="TEabrEPvFxSMDxAIj"
If DKlwXpLfoDEuvfs="TEabrEPvFxSMDxAIj"Then
End If
|
Option Explicit
Function GetOneTokenFromString(SrcString)
Dim OneToken As String
Dim Pos As Integer
Pos = InStr(SrcString, " ")
If (Pos > 0) Then
OneToken = Left(SrcString, Pos - 1)
SrcString = Mid(SrcString, Pos + 1)
GetOneTokenFromString = OneToken
Else
GetOneTokenFromString = SrcString
SrcString = ""
End If
End Function
Function GetOneToken(FileNumber)
Dim OneToken As String
Dim OneChar
Do While Not EOF(FileNumber)
OneChar = Input(1, FileNumber)
If (OneChar = " ") Then
GetOneToken = OneToken
Exit Function
Else
OneToken = OneToken & OneChar
End If
Loop
GetOneToken = OneToken
End Function
Function GetOneLine(FileNumber)
Dim OneLine As String
Input #FileNumber, OneLine
GetOneLine = OneLine
End Function
Sub ProcessFile(FileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
On Error Resume Next
Dim OneLine As String
Dim OneToken As String
Dim ByteRcved As Long
Dim ByteSent As Long
Dim TimeProcessed As Long
Dim AspTimeProcessed As Long
Dim RecvBytesIndex, TimeIndex, UrlIndex
Dim I
Dim bAsp As Boolean
Dim bPrinter As Boolean
TotalAspHits = 0
TotalPPHits = 0
ByteRcved = 0
ByteSent = 0
TimeProcessed = 0
AspTimeProcessed = 0
Open FileName For Input As #1
If Err.Number Then
Exit Sub
End If
Do While Not EOF(1)
OneLine = GetOneLine(1)
If Left(OneLine, 1) = "#" Then
If Left(OneLine, 8) = "#Fields:" Then
OneToken = GetOneTokenFromString(OneLine)
I = 0
Do While OneToken <> ""
OneToken = GetOneTokenFromString(OneLine)
Select Case OneToken
Case "cs-uri-stem"
UrlIndex = I
Case "cs-bytes"
RecvBytesIndex = I
Case "time-taken"
TimeIndex = I
Case Else
End Select
I = I + 1
Loop
End If
Else
I = 0
bAsp = False
bPrinter = False
Do While I = 0 Or OneToken <> ""
OneToken = GetOneTokenFromString(OneLine)
If I = UrlIndex Then
'Process the URL
Const strPrn = "/.printer"
Const strPrns = "printers"
Const strAsp = ".asp"
If Right(OneToken, Len(strPrn)) = strPrn Then
bPrinter = True
TotalPPHits = TotalPPHits + 1
ElseIf Left(OneToken, Len(strPrns)) = strPrns And Right(OneToken, Len(strAsp)) = strAsp Then
bPrinter = True
TotalAspHits = TotalAspHits + 1
End If
End If
If bAsp Then
If I = TimeIndex Then
AspTimeProcessed = AspTimeProcessed + Val(OneToken)
End If
End If
If bPrinter Then
If I = RecvBytesIndex Then
ByteRcved = ByteRcved + Val(OneToken)
End If
If I = TimeIndex Then
TimeProcessed = TimeProcessed + Val(OneToken)
End If
End If
I = I + 1
Loop
End If
Loop
Close #1
If TotalAspHits > 0 Then
AvgAspTime = AspTimeProcessed / TotalAspHits
End If
If ByteRcved > 0 Then
AvgPPTime = TimeProcessed / ByteRcved
End If
TotalPPBytesRcved = ByteRcved
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub FileNameOK_Click()
Dim MyDate As String * 300
Dim MyTime As String * 9
Dim MyString As String
Dim FileName As String
Dim TotalAspHits, TotalPPHits
Dim AvgAspTime As Double
Dim AvgPPTime As Double
Dim TotalPPBytesRcved As Long
Dim strEol As String
Dim args, argc
args = GetCommandLine()
If UBound(args) >= 1 Then
Form1.Text1 = args(1)
End If
'FileName = "d:\public\ex980207.log"
FileName = Form1.Text1
'FileName = "d:\public\ex" & Form1.YearTxt & Form1.MonthTxt & Form1.DayTxt & ".log"
Call ProcessFile(FileName, TotalAspHits, TotalPPHits, TotalPPBytesRcved, AvgAspTime, AvgPPTime)
strEol = Chr$(13) & Chr$(10)
Result.Text = "Total .printer Hits = " & TotalPPHits & strEol
Result.Text = Result.Text & "Total Bytes Printed = " & TotalPPBytesRcved & strEol
Result.Text = Result.Text & "Total ASP Hits = " & TotalAspHits & strEol
Result.Text = Result.Text & "Avg Asp Time (msec/hit) = " & Format(AvgAspTime, "###0.00") & strEol
Result.Text = Result.Text & "Avg PP Time (msec/byte) = " & Format(AvgPPTime, "###0.00") & strEol
'Result.Text
Debug.Print "Total .printer Hits = " & TotalPPHits
Debug.Print "Total Bytes Printed = " & TotalPPBytesRcved
Debug.Print "Avg Asp Time (msec/hit) = "; AvgAspTime
Debug.Print "Avg PP Time (msec/byte) = "; AvgPPTime
Debug.Print "Total ASP Hits = " & TotalAspHits
Debug.Print "Total .printer Hits = " & TotalPPHits
Debug.Print "Total Bytes Printed = " & TotalPPBytesRcved
Debug.Print "Avg Asp Time (msec/hit) = "; AvgAspTime
Debug.Print "Avg PP Time (msec/byte) = "; AvgPPTime
End Sub
Private Sub Form_Load()
Call FileNameOK_Click
End Sub
Function GetCommandLine(Optional MaxArgs)
'Declare variables.
Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
'See if MaxArgs was provided.
If IsMissing(MaxArgs) Then MaxArgs = 10
'Make array of the correct size.
ReDim ArgArray(MaxArgs)
NumArgs = 0: InArg = False
'Get command line arguments.
CmdLine = Command()
CmdLnLen = Len(CmdLine)
'Go thru command line one character
'at a time.
For I = 1 To CmdLnLen
C = Mid(CmdLine, I, 1)
'Test for space or tab.
If (C <> " " And C <> vbTab) Then
'Neither space nor tab.
'Test if already in argument.
If Not InArg Then
'New argument begins.
'Test for too many arguments.
If NumArgs = MaxArgs Then Exit For
NumArgs = NumArgs + 1
InArg = True
End If
'Concatenate character to current argument.
ArgArray(NumArgs) = ArgArray(NumArgs) & C
Else
'Found a space or tab.
'Set InArg flag to False.
InArg = False
End If
Next I
'Resize array just enough to hold arguments.
ReDim Preserve ArgArray(NumArgs)
'Return Array in Function name.
GetCommandLine = ArgArray()
End Function
|
Option Explicit
Sub Main()
Debug.Print fFormat(13, 2, 1230.3333)
Debug.Print fFormat(2, 13, 1230.3333)
Debug.Print fFormat(10, 5, 0.3333)
Debug.Print fFormat(13, 2, 1230)
End Sub
Private Function fFormat(NbInt As Integer, NbDec As Integer, Nb As Double) As String
'NbInt : Lenght of integral part
'NbDec : Lenght of decimal part
'Nb : decimal on integer number
Dim u As String, v As String, i As Integer
u = CStr(Nb)
i = InStr(u, Application.DecimalSeparator)
If i > 0 Then
v = Mid(u, i + 1)
u = Left(u, i - 1)
fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & Left(v & String(NbDec, "0"), NbDec)
Else
fFormat = Right(String(NbInt, "0") & u, NbInt) & Application.DecimalSeparator & String(NbDec, "0")
End If
End Function
|
<gh_stars>10-100
on error resume next
set service = GetObject ("winmgmts:{impersonationLevel=impersonate}")
if err <> 0 then
WScript.Echo Hex(Err.Number), Err.Description, Err.Source
end if
set processes = service.instancesof ("Win32_Process")
for each process in processes
if IsNull(process.priority) then
WScript.Echo process.Name, process.handle, "<NULL>"
else
WScript.Echo process.name, process.handle, process.priority
end if
next
if err <> 0 then
WScript.Echo Err.Number, Err.Description, Err.Source
end if
|
for each Service in _
GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_service")
WScript.Echo ""
WScript.Echo Service.Description & ":" & Service.State
next
|
'***************************************************************************
'This script tests the manipulation of context values, in the case that the
'context value is a not an array type
'***************************************************************************
Set Context = CreateObject("WbemScripting.SWbemNamedValueSet")
On Error Resume Next
Context.Add "n1", 327
WScript.Echo "The initial value of n1 is [327]:", Context("n1")
'Verify we can report the context value
v = Context("n1")
WScript.Echo "By indirection n1 has value [327]:",v
'Verify we can report the value directly
WScript.Echo "By direct access n1 has value [327]:", Context("n1")
'Verify we can set the value of a single named value
Context("n1") = 234
WScript.Echo "After direct assignment n1 has value [234]:", Context("n1")
if Err <> 0 Then
WScript.Echo Err.Description
Err.Clear
End if
|
<reponame>djgoku/RosettaCodeData<filename>Task/URL-decoding/VBScript/url-decoding.vb
Function UrlDecode(s)
For i = 1 To Len(s)
If Mid(s,i,1) = "%" Then
UrlDecode = UrlDecode & Chr("&H" & Mid(s,i+1,2))
i = i + 2
Else
UrlDecode = UrlDecode & Mid(s,i,1)
End If
Next
End Function
url = "http%3A%2F%2Ffoo%20bar%2F"
WScript.Echo "Encoded URL: " & url & vbCrLf &_
"Decoded URL: " & UrlDecode(url)
|
<filename>admin/pchealth/authtools/prodtools/common/exporter.bas
Attribute VB_Name = "Exporter"
Option Explicit
Private Const ERROR_STRING_C As String = "!!!ERROR!!!"
Public Sub Export2XL( _
ByVal i_rs As ADODB.Recordset, _
ByVal i_strFileName As String, _
ByVal i_strTabName As String _
)
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset
cnn.Open "DRIVER=Microsoft Excel Driver (*.xls);ReadOnly=0;DBQ=" & i_strFileName & ";HDR=0;"
cnn.Execute "Create table " & i_strTabName & p_GetFieldCreationInfo(i_rs)
rs.Open "Select * from `" & i_strTabName & "$`", cnn, adOpenForwardOnly, adLockOptimistic
If (i_rs.RecordCount > 0) Then
i_rs.MoveFirst
End If
On Error Resume Next
Do While (Not i_rs.EOF)
rs.AddNew
For Each fld In i_rs.Fields
rs(fld.Name) = fld.Value
If (Err.Number <> 0) Then
Err.Clear
If (fld.Type = adVarWChar) Then
rs(fld.Name) = ERROR_STRING_C
End If
End If
Next
rs.Update
i_rs.MoveNext
DoEvents
Loop
End Sub
Private Function p_GetFieldCreationInfo( _
ByVal i_rs As ADODB.Recordset _
) As String
Dim fld As ADODB.Field
Dim str As String
Dim blnFirstField As Boolean
str = "("
blnFirstField = True
For Each fld In i_rs.Fields
If (Not blnFirstField) Then
str = str & ","
Else
blnFirstField = False
End If
str = str & fld.Name
Select Case fld.Type
Case adVarWChar
str = str & " text"
Case adInteger
str = str & " long"
Case adBoolean
str = str & " bit"
Case adDate
str = str & " date"
Case Else
str = str & " text"
End Select
Next
str = str & ")"
p_GetFieldCreationInfo = str
End Function
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.