<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>VBForums - ASP, VB Script</title>
		<link>http://www.vbforums.com/</link>
		<description>This forum is the place to post all your questions about using the Internet within your applications. Topics include: writing components for ASP (classic), VB Script, and more.</description>
		<language>en</language>
		<lastBuildDate>Sat, 25 May 2013 01:12:54 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.vbforums.com/images/misc/rss.png</url>
			<title>VBForums - ASP, VB Script</title>
			<link>http://www.vbforums.com/</link>
		</image>
		<item>
			<title>VBScript to VB.NET Conversion</title>
			<link>http://www.vbforums.com/showthread.php?722317-VBScript-to-VB-NET-Conversion&amp;goto=newpost</link>
			<pubDate>Mon, 20 May 2013 21:52:03 GMT</pubDate>
			<description><![CDATA[Hello. I've been looking online all over for a VBScript to VB.NET converter, but of course, they are incompatible.

Could someone rewrite these three into VB.NET for me, please?

revert_version.vbs

Code:
---------
on error resume next
set fso = createobject("scripting.filesystemobject")
set shell = createobject("shell.application")
revision_file = wscript.arguments.item(0)
revision_folder = fso.getparentfoldername(revision_file)
fso.movefile revision_file , left(revision_file,len(revision_file)-8)&".zip"
set zipfile = shell.namespace(left(revision_file,len(revision_file)-8)&".zip")
set srcfolder = shell.namespace(revision_folder)
for each item in srcfolder.items
if (item.type <> "VERSION File") and (item.name <> fso.getfilename(left(revision_file,len(revision_file)-8)&".zip")) then
if item.isfolder then
fso.deletefolder(item.path)
else
fso.deletefile(item.path)
end if
end if
next
for each item in zipfile.items
srcfolder.copyhere item
next
fso.movefile left(revision_file,len(revision_file)-8)&".zip" , revision_file
---------
create_backup.vbs

Code:
---------
on error resume next
set shell = createobject("shell.application")
set fso = createobject("scripting.filesystemobject")
newfilename = "__BACKUP_"&replace(cstr(date),"/","_")&" "&replace(cstr(time),":","_")
set zipfile = fso.createtextfile(wscript.arguments.item(0)&"\"&newfilename&".zip")
zipfile.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
zipfile.close
set zipfile = shell.namespace(wscript.arguments.item(0)&"\"&newfilename&".zip")
set srcfolder = shell.namespace(wscript.arguments.item(0)&"\")
for each item in srcfolder.items
wscript.sleep 500
if (item.type <> "BACKUP File") and (item.name <> (newfilename&".zip")) then
zipfile.copyhere item
end if
next
' the following loop waits until the script has finished adding files to the zip file
set zipfile2 = fso.getfile(wscript.arguments.item(0)&"\"&newfilename&".zip")
do
zipfile2_size = zipfile2.size
wscript.sleep 100
loop while zipfile2.size > zipfile2_size
wscript.sleep 100
fso.movefile wscript.arguments.item(0)&"\"&newfilename&".zip" , wscript.arguments.item(0)&"\"&newfilename&".backup"
---------
new_revision.vbs

Code:
---------
on error resume next
set shell = createobject("shell.application")
set fso = createobject("scripting.filesystemobject")
newfilename = "__REVISION_"&replace(cstr(date),"/","_")&" "&replace(cstr(time),":","_")
set zipfile = fso.createtextfile(wscript.arguments.item(0)&"\"&newfilename&".zip")
zipfile.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
zipfile.close
set zipfile = shell.namespace(wscript.arguments.item(0)&"\"&newfilename&".zip")
set srcfolder = shell.namespace(wscript.arguments.item(0)&"\")
set zipfile2 = fso.getfile(wscript.arguments.item(0)&"\"&newfilename&".zip")
wscript.sleep 500
for each item in srcfolder.items
wscript.echo item.name
wscript.sleep 500
if (item.type <> "VERSION File") and (item.type <> "Compressed (zipped) Folder" ) then
zipfile.copyhere item
do
zipfile2_size = zipfile2.size
wscript.sleep 100
loop while zipfile2.size > zipfile2_size
end if
next
' the following loop waits until the script has finished adding files to the zip file
wscript.sleep 100
fso.movefile wscript.arguments.item(0)&"\"&newfilename&".zip" , wscript.arguments.item(0)&"\"&newfilename&".version"
---------
Thanks.

I couldn't attach them, because they were not blocked by the filter.]]></description>
			<content:encoded><![CDATA[<div>Hello. I've been looking online all over for a VBScript to VB.NET converter, but of course, they are incompatible.<br />
<br />
Could someone rewrite these three into VB.NET for me, please?<br />
<br />
revert_version.vbs<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">on error resume next<br />
set fso = createobject(&quot;scripting.filesystemobject&quot;)<br />
set shell = createobject(&quot;shell.application&quot;)<br />
revision_file = wscript.arguments.item(0)<br />
revision_folder = fso.getparentfoldername(revision_file)<br />
fso.movefile revision_file , left(revision_file,len(revision_file)-8)&amp;&quot;.zip&quot;<br />
set zipfile = shell.namespace(left(revision_file,len(revision_file)-8)&amp;&quot;.zip&quot;)<br />
set srcfolder = shell.namespace(revision_folder)<br />
for each item in srcfolder.items<br />
if (item.type &lt;&gt; &quot;VERSION File&quot;) and (item.name &lt;&gt; fso.getfilename(left(revision_file,len(revision_file)-8)&amp;&quot;.zip&quot;)) then<br />
if item.isfolder then<br />
fso.deletefolder(item.path)<br />
else<br />
fso.deletefile(item.path)<br />
end if<br />
end if<br />
next<br />
for each item in zipfile.items<br />
srcfolder.copyhere item<br />
next<br />
fso.movefile left(revision_file,len(revision_file)-8)&amp;&quot;.zip&quot; , revision_file</code><hr />
</div>create_backup.vbs<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">on error resume next<br />
set shell = createobject(&quot;shell.application&quot;)<br />
set fso = createobject(&quot;scripting.filesystemobject&quot;)<br />
newfilename = &quot;__BACKUP_&quot;&amp;replace(cstr(date),&quot;/&quot;,&quot;_&quot;)&amp;&quot; &quot;&amp;replace(cstr(time),&quot;:&quot;,&quot;_&quot;)<br />
set zipfile = fso.createtextfile(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
zipfile.write(&quot;PK&quot; &amp; chr(5) &amp; chr(6) &amp; string(18,chr(0)))<br />
zipfile.close<br />
set zipfile = shell.namespace(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
set srcfolder = shell.namespace(wscript.arguments.item(0)&amp;&quot;\&quot;)<br />
for each item in srcfolder.items<br />
wscript.sleep 500<br />
if (item.type &lt;&gt; &quot;BACKUP File&quot;) and (item.name &lt;&gt; (newfilename&amp;&quot;.zip&quot;)) then<br />
zipfile.copyhere item<br />
end if<br />
next<br />
' the following loop waits until the script has finished adding files to the zip file<br />
set zipfile2 = fso.getfile(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
do<br />
zipfile2_size = zipfile2.size<br />
wscript.sleep 100<br />
loop while zipfile2.size &gt; zipfile2_size<br />
wscript.sleep 100<br />
fso.movefile wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot; , wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.backup&quot;</code><hr />
</div>new_revision.vbs<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">on error resume next<br />
set shell = createobject(&quot;shell.application&quot;)<br />
set fso = createobject(&quot;scripting.filesystemobject&quot;)<br />
newfilename = &quot;__REVISION_&quot;&amp;replace(cstr(date),&quot;/&quot;,&quot;_&quot;)&amp;&quot; &quot;&amp;replace(cstr(time),&quot;:&quot;,&quot;_&quot;)<br />
set zipfile = fso.createtextfile(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
zipfile.write(&quot;PK&quot; &amp; chr(5) &amp; chr(6) &amp; string(18,chr(0)))<br />
zipfile.close<br />
set zipfile = shell.namespace(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
set srcfolder = shell.namespace(wscript.arguments.item(0)&amp;&quot;\&quot;)<br />
set zipfile2 = fso.getfile(wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot;)<br />
wscript.sleep 500<br />
for each item in srcfolder.items<br />
wscript.echo item.name<br />
wscript.sleep 500<br />
if (item.type &lt;&gt; &quot;VERSION File&quot;) and (item.type &lt;&gt; &quot;Compressed (zipped) Folder&quot; ) then<br />
zipfile.copyhere item<br />
do<br />
zipfile2_size = zipfile2.size<br />
wscript.sleep 100<br />
loop while zipfile2.size &gt; zipfile2_size<br />
end if<br />
next<br />
' the following loop waits until the script has finished adding files to the zip file<br />
wscript.sleep 100<br />
fso.movefile wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.zip&quot; , wscript.arguments.item(0)&amp;&quot;\&quot;&amp;newfilename&amp;&quot;.version&quot;</code><hr />
</div>Thanks.<br />
<br />
I couldn't attach them, because they were not blocked by the filter.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>Tosaka Kawashita</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?722317-VBScript-to-VB-NET-Conversion</guid>
		</item>
		<item>
			<title>ASP to VB conversion for a web method</title>
			<link>http://www.vbforums.com/showthread.php?722013-ASP-to-VB-conversion-for-a-web-method&amp;goto=newpost</link>
			<pubDate>Fri, 17 May 2013 16:41:19 GMT</pubDate>
			<description><![CDATA[I need the following code converted to VB to work in a web method I am creating.  I had tried a few different things with no success.  Hoping someone might be able to help me out. Thanks!

        strSQL = "SELECT @@IDENTITY AS recid"
	Set rsTemp = ocnComp.Execute(strSQL)
	If Not rsTemp.EOF Then
		strRecid = Trim(rsTemp("recid"))

		i = 0
		Do While Len(arrParts(i, 0)) > 0

			' Create the INSERT statement for the 'detail' table.
			strSQL = "INSERT INTO seqexp_detail (recid, custpart, qty, comment, who, active) " & _
					 "VALUES (" & strRecid & ", '" & arrParts(i, 0) & "', '" & arrParts(i, 1) & "', '" & arrParts(i, 2) & "', '" & arrParts(i, 3) & "', 1)"
			'ocnComp.Execute(strSQL)
			i = i + 1

		Loop]]></description>
			<content:encoded><![CDATA[<div>I need the following code converted to VB to work in a web method I am creating.  I had tried a few different things with no success.  Hoping someone might be able to help me out. Thanks!<br />
<br />
        strSQL = &quot;SELECT @@IDENTITY AS recid&quot;<br />
	Set rsTemp = ocnComp.Execute(strSQL)<br />
	If Not rsTemp.EOF Then<br />
		strRecid = Trim(rsTemp(&quot;recid&quot;))<br />
<br />
		i = 0<br />
		Do While Len(arrParts(i, 0)) &gt; 0<br />
<br />
			' Create the INSERT statement for the 'detail' table.<br />
			strSQL = &quot;INSERT INTO seqexp_detail (recid, custpart, qty, comment, who, active) &quot; &amp; _<br />
					 &quot;VALUES (&quot; &amp; strRecid &amp; &quot;, '&quot; &amp; arrParts(i, 0) &amp; &quot;', '&quot; &amp; arrParts(i, 1) &amp; &quot;', '&quot; &amp; arrParts(i, 2) &amp; &quot;', '&quot; &amp; arrParts(i, 3) &amp; &quot;', 1)&quot;<br />
			'ocnComp.Execute(strSQL)<br />
			i = i + 1<br />
<br />
		Loop</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>rkear89</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?722013-ASP-to-VB-conversion-for-a-web-method</guid>
		</item>
		<item>
			<title><![CDATA[Using LDAP to move OU's in ADSI]]></title>
			<link>http://www.vbforums.com/showthread.php?721995-Using-LDAP-to-move-OU-s-in-ADSI&amp;goto=newpost</link>
			<pubDate>Fri, 17 May 2013 13:07:28 GMT</pubDate>
			<description><![CDATA[Hello there. 

  I have an ADSI server, and i have the following structure on it:


   OU Laboratory           
            OU Blocked       
                    OU PC_1    
                    OU PC_2    
             OU NOTBLOCKED
                    OU PC_3    
                    OU PC_4    


The computers are OUs, with Computers inside OUS (in fact the PC represents a laboratory room in our university). 

So i have an ASP function, that will recieve a BLOCKED pc name, and move it to the NOTBLOCKED OU, but i am not managing to do so.

This is the far i could go:


Code:
---------

		Set ou = dso.OpenDSObject("LDAP://IP/ou=" & pcName & ",ou=Blocked,ou=Labs,dc=acd,dc=puc-campinas,dc=edu,dc=br", "user", "pass", 1)
		ou.MoveHere "LDAP://IP/ou=NotBlocked,ou=Labs,dc=acd,dc=puc-campinas,dc=edu,dc=br", "ou=" & pcName
---------
It doesnt work :( Im not sure how could i make this happen. 

Would really apreciate any help ! Thanks alot for the time !]]></description>
			<content:encoded><![CDATA[<div>Hello there. <br />
<br />
  I have an ADSI server, and i have the following structure on it:<br />
<br />
<br />
   OU Laboratory           <br />
            OU Blocked       <br />
                    OU PC_1    <br />
                    OU PC_2    <br />
             OU NOTBLOCKED<br />
                    OU PC_3    <br />
                    OU PC_4    <br />
<br />
<br />
The computers are OUs, with Computers inside OUS (in fact the PC represents a laboratory room in our university). <br />
<br />
So i have an ASP function, that will recieve a BLOCKED pc name, and move it to the NOTBLOCKED OU, but i am not managing to do so.<br />
<br />
This is the far i could go:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code"><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set ou = dso.OpenDSObject(&quot;LDAP://IP/ou=&quot; &amp; pcName &amp; &quot;,ou=Blocked,ou=Labs,dc=acd,dc=puc-campinas,dc=edu,dc=br&quot;, &quot;user&quot;, &quot;pass&quot;, 1)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ou.MoveHere &quot;LDAP://IP/ou=NotBlocked,ou=Labs,dc=acd,dc=puc-campinas,dc=edu,dc=br&quot;, &quot;ou=&quot; &amp; pcName</code><hr />
</div>It doesnt work :( Im not sure how could i make this happen. <br />
<br />
Would really apreciate any help ! Thanks alot for the time !</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>gslomka</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721995-Using-LDAP-to-move-OU-s-in-ADSI</guid>
		</item>
		<item>
			<title><![CDATA[To abruptly end a  vb script when user clicks on "Esc" button!!]]></title>
			<link>http://www.vbforums.com/showthread.php?721647-To-abruptly-end-a-vb-script-when-user-clicks-on-quot-Esc-quot-button!!&amp;goto=newpost</link>
			<pubDate>Tue, 14 May 2013 18:41:24 GMT</pubDate>
			<description><![CDATA[Here is my code written:-

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run " "
WScript.Sleep 5000
for i=1 to 20 
WshShell.SendKeys "^{HOME}"
WshShell.SendKeys "{END}"
WScript.Sleep 50
WshShell.SendKeys " or "
WScript.Sleep 50
WshShell.SendKeys "{DELETE}"
WshShell.SendKeys "{END}"
next

Result of this code basically add's "or" onto any active window! This was written to help me in adding the text "or" in between two values. I run this code and place a notepad as active window which has values. but if i click and open any other window, this code continues untill " i = 20 " but i have to exit from this code if user("I") clicks on "Esc" button. Can somebody provide me solution to it.
I know there is wshShell.Quit....and i truely dont know how to use it!!]]></description>
			<content:encoded><![CDATA[<div>Here is my code written:-<br />
<br />
Set WshShell = WScript.CreateObject(&quot;WScript.Shell&quot;)<br />
WshShell.Run &quot; &quot;<br />
WScript.Sleep 5000<br />
for i=1 to 20 <br />
WshShell.SendKeys &quot;^{HOME}&quot;<br />
WshShell.SendKeys &quot;{END}&quot;<br />
WScript.Sleep 50<br />
WshShell.SendKeys &quot; or &quot;<br />
WScript.Sleep 50<br />
WshShell.SendKeys &quot;{DELETE}&quot;<br />
WshShell.SendKeys &quot;{END}&quot;<br />
next<br />
<br />
Result of this code basically add's &quot;or&quot; onto any active window! This was written to help me in adding the text &quot;or&quot; in between two values. I run this code and place a notepad as active window which has values. but if i click and open any other window, this code continues untill &quot; i = 20 &quot; but i have to exit from this code if user(&quot;I&quot;) clicks on &quot;Esc&quot; button. Can somebody provide me solution to it.<br />
I know there is wshShell.Quit....and i truely dont know how to use it!!</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>Raj_123</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721647-To-abruptly-end-a-vb-script-when-user-clicks-on-quot-Esc-quot-button!!</guid>
		</item>
		<item>
			<title>Delete a file with a given extension</title>
			<link>http://www.vbforums.com/showthread.php?721601-Delete-a-file-with-a-given-extension&amp;goto=newpost</link>
			<pubDate>Tue, 14 May 2013 10:36:08 GMT</pubDate>
			<description><![CDATA[Hi All,

Wondering if anyone can help, I'm attempting to delete a .ost file from a users roaming profile, I'm using the following code:

*Dim strComputer, oWSH, oWMI, oFSO, AppDataFolder

strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set oWSH = CreateObject("WScript.Shell") 
Set oFSO = CreateObject("Scripting.FileSystemObject") 
AppDataFolder = oWSH.ExpandEnvironmentStrings("%appdata%") 

For Each file As String In IO.Directory.GetFiles(AppDataFolder & "\Thinstall\Microsoft Standard 2010 KMS\%Local AppData%\Microsoft\Outlook","*.ost")
  IO.File.Delete(file)
Next*

I keep getting "Expected In" error message on line 9 char 15. Any idea why? Sorry but I literally do no VB coding so am a bit lost.

Regards,
Ross]]></description>
			<content:encoded><![CDATA[<div>Hi All,<br />
<br />
Wondering if anyone can help, I'm attempting to delete a .ost file from a users roaming profile, I'm using the following code:<br />
<br />
<b>Dim strComputer, oWSH, oWMI, oFSO, AppDataFolder<br />
<br />
strComputer = &quot;.&quot;<br />
Set oWMI = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\cimv2&quot;) <br />
Set oWSH = CreateObject(&quot;WScript.Shell&quot;) <br />
Set oFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;) <br />
AppDataFolder = oWSH.ExpandEnvironmentStrings(&quot;%appdata%&quot;) <br />
<br />
For Each file As String In IO.Directory.GetFiles(AppDataFolder &amp; &quot;\Thinstall\Microsoft Standard 2010 KMS\%Local AppData%\Microsoft\Outlook&quot;,&quot;*.ost&quot;)<br />
  IO.File.Delete(file)<br />
Next</b><br />
<br />
I keep getting &quot;Expected In&quot; error message on line 9 char 15. Any idea why? Sorry but I literally do no VB coding so am a bit lost.<br />
<br />
Regards,<br />
Ross</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>thamoomin81</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721601-Delete-a-file-with-a-given-extension</guid>
		</item>
		<item>
			<title>function in visual basic</title>
			<link>http://www.vbforums.com/showthread.php?721001-function-in-visual-basic&amp;goto=newpost</link>
			<pubDate>Thu, 09 May 2013 08:11:50 GMT</pubDate>
			<description><![CDATA[Hi, i wrote a procedure and function. I transfer this function into procedure. If i try execute procedure i have an error: argument not optional on this function.


Code:
---------
Public Function inserthgbstshow(level As String, relation As Long) As String

    Dim funObjid As Long
    funObjid_show = pobierz_objid(ptype_id_inserthgbstshow)
    
    conn.Execute "insert into table_hgbst_show(OBJID, LAST_MOD_TIME, TITLE, DEV_VAL, DEV, CHLD_PRNT2HGBST_SHOW) values (" + funObjid_show + ", to date(1753-01-01), '" + level + "', 0, "", " + relation + ")"
    inserthgbstshow = funObjid_show
End Function
---------


Code:
---------
Sub Zaimportuj()
    Dim objid_show_level_1 As Long
    Dim objid_show_level_2 As Long
    Dim objid_show_level_3 As Long
    Dim objid_show_level_4 As Long
    Dim objid_show_level_5 As Long
    Dim last_name_level_1 As String
    Dim last_name_level_2 As String
    Dim last_name_level_3 As String
    Dim last_name_level_4 As String
    Dim last_name_level_5 As String
    
    objid_show_level_1 = pobierz_list
    
    delete_dane
    
    last_name_level_1 = ""
    last_name_level_2 = ""
    last_name_level_3 = ""
    last_name_level_4 = ""
    last_name_level_5 = ""
    
    Dim c As Object
    
With Sheets(1).Range("A:A")
Set c = .Find(what:="*", LookIn:=xlValues, LookAt:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)
End With
MsgBox ("Ostatni zapisany wiersz to: " & c.Row)
Dim x As Integer
x = 3
For x = 3 To c.Row
    If Range("B" + CStr(x)) <> "" Then
        
        inserthgbstelement
        inserthgbstelm0hgbstshow1
        
    If Range("D" + CStr(x)) <> "" Then
        If last_name_level_1 <> Range("A" + CStr(x)) Then
            objid_show_level_2 = inserthgbstshow
        End If
        inserthgbstelement
        inserthgbstelm0hgbstshow1
    
    If Range("F" + CStr(x)) <> "" Then
        If last_name_level_2 <> Range("C" + CStr(x)) Then
            objid_show_level_3 = inserthgbstshow
        End If
        inserthgbstelement
        inserthgbstelm0hgbstshow1
    
    If Range("H" + CStr(x)) <> "" Then
        If last_name_level_3 <> Range("E" + CStr(x)) Then
            objid_show_level_4 = inserthgbstshow
        End If
        inserthgbstelement
        inserthgbstelm0hgbstshow1
    
    If Range("J" + CStr(x)) <> "" Then
        If last_name_level_4 <> Range("G" + CStr(x)) Then
            objid_show_level_5 = inserthgbstshow
        End If
        inserthgbstelement
        inserthgbstelm0hgbstshow1
                
                End If
             End If
        End If
    End If
    
    last_name_level_1 = Range("A" + CStr(x))
    last_name_level_2 = Range("C" + CStr(x))
    last_name_level_3 = Range("E" + CStr(x))
    last_name_level_4 = Range("G" + CStr(x))
    last_name_level_5 = Range("I" + CStr(x))
End If
Next x
End Sub
---------
]]></description>
			<content:encoded><![CDATA[<div>Hi, i wrote a procedure and function. I transfer this function into procedure. If i try execute procedure i have an error: argument not optional on this function.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Public Function inserthgbstshow(level As String, relation As Long) As String<br />
<br />
&nbsp; &nbsp; Dim funObjid As Long<br />
&nbsp; &nbsp; funObjid_show = pobierz_objid(ptype_id_inserthgbstshow)<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; conn.Execute &quot;insert into table_hgbst_show(OBJID, LAST_MOD_TIME, TITLE, DEV_VAL, DEV, CHLD_PRNT2HGBST_SHOW) values (&quot; + funObjid_show + &quot;, to date(1753-01-01), '&quot; + level + &quot;', 0, &quot;&quot;, &quot; + relation + &quot;)&quot;<br />
&nbsp; &nbsp; inserthgbstshow = funObjid_show<br />
End Function</code><hr />
</div><br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">Sub Zaimportuj()<br />
&nbsp; &nbsp; Dim objid_show_level_1 As Long<br />
&nbsp; &nbsp; Dim objid_show_level_2 As Long<br />
&nbsp; &nbsp; Dim objid_show_level_3 As Long<br />
&nbsp; &nbsp; Dim objid_show_level_4 As Long<br />
&nbsp; &nbsp; Dim objid_show_level_5 As Long<br />
&nbsp; &nbsp; Dim last_name_level_1 As String<br />
&nbsp; &nbsp; Dim last_name_level_2 As String<br />
&nbsp; &nbsp; Dim last_name_level_3 As String<br />
&nbsp; &nbsp; Dim last_name_level_4 As String<br />
&nbsp; &nbsp; Dim last_name_level_5 As String<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; objid_show_level_1 = pobierz_list<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; delete_dane<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; last_name_level_1 = &quot;&quot;<br />
&nbsp; &nbsp; last_name_level_2 = &quot;&quot;<br />
&nbsp; &nbsp; last_name_level_3 = &quot;&quot;<br />
&nbsp; &nbsp; last_name_level_4 = &quot;&quot;<br />
&nbsp; &nbsp; last_name_level_5 = &quot;&quot;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Dim c As Object<br />
&nbsp; &nbsp; <br />
With Sheets(1).Range(&quot;A:A&quot;)<br />
Set c = .Find(what:=&quot;*&quot;, LookIn:=xlValues, LookAt:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)<br />
End With<br />
MsgBox (&quot;Ostatni zapisany wiersz to: &quot; &amp; c.Row)<br />
Dim x As Integer<br />
x = 3<br />
For x = 3 To c.Row<br />
&nbsp; &nbsp; If Range(&quot;B&quot; + CStr(x)) &lt;&gt; &quot;&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelement<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelm0hgbstshow1<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; If Range(&quot;D&quot; + CStr(x)) &lt;&gt; &quot;&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; If last_name_level_1 &lt;&gt; Range(&quot;A&quot; + CStr(x)) Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objid_show_level_2 = inserthgbstshow<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelement<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelm0hgbstshow1<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If Range(&quot;F&quot; + CStr(x)) &lt;&gt; &quot;&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; If last_name_level_2 &lt;&gt; Range(&quot;C&quot; + CStr(x)) Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objid_show_level_3 = inserthgbstshow<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelement<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelm0hgbstshow1<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If Range(&quot;H&quot; + CStr(x)) &lt;&gt; &quot;&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; If last_name_level_3 &lt;&gt; Range(&quot;E&quot; + CStr(x)) Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objid_show_level_4 = inserthgbstshow<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelement<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelm0hgbstshow1<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; If Range(&quot;J&quot; + CStr(x)) &lt;&gt; &quot;&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; If last_name_level_4 &lt;&gt; Range(&quot;G&quot; + CStr(x)) Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objid_show_level_5 = inserthgbstshow<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelement<br />
&nbsp; &nbsp; &nbsp; &nbsp; inserthgbstelm0hgbstshow1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; End If<br />
&nbsp; &nbsp; End If<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; last_name_level_1 = Range(&quot;A&quot; + CStr(x))<br />
&nbsp; &nbsp; last_name_level_2 = Range(&quot;C&quot; + CStr(x))<br />
&nbsp; &nbsp; last_name_level_3 = Range(&quot;E&quot; + CStr(x))<br />
&nbsp; &nbsp; last_name_level_4 = Range(&quot;G&quot; + CStr(x))<br />
&nbsp; &nbsp; last_name_level_5 = Range(&quot;I&quot; + CStr(x))<br />
End If<br />
Next x<br />
End Sub</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>kaczak1108</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?721001-function-in-visual-basic</guid>
		</item>
		<item>
			<title>Object not in collection</title>
			<link>http://www.vbforums.com/showthread.php?720961-Object-not-in-collection&amp;goto=newpost</link>
			<pubDate>Wed, 08 May 2013 16:47:24 GMT</pubDate>
			<description><![CDATA[Hello,

I am having a similar error and would like to ask why the script abandons and returns "Object not in collection"
It's also writing out a text file.


Code:
---------
str_boxname = WScript.Arguments( 0 )

const HKEY_LOCAL_MACHINE = &H80000002
DIM var_IPS
DIM var_Domain
DIM var_SERVERNAME
DIM var_VERSION
DIM var_OS
DIM var_OSVersion
DIM var_OSSP
DIM var_FDQN
DIM var_InstanceName
DIM var_port
DIM var_connection
DIM var_isCluster

var_SERVERNAME 	= f_servername(str_boxname)
var_Domain 		= f_DOMAIN(var_SERVERNAME)
var_OS 			= f_OS(var_SERVERNAME)
var_OSVersion   = f_OSVersion(var_SERVERNAME)
var_OSSP        = f_OSSP(var_SERVERNAME)
var_IPS 		= f_IPS(var_SERVERNAME)
var_FDQN        = f_fdqn(var_SERVERNAME)
var_CLUSTER     = f_CLUSTER(var_SERVERNAME)
OutputFile="c:\temp\" & "EPinventory." & var_SERVERNAME 
Set oFSO = CreateObject("Scripting.FilesyStemObject")
Set ofile = ofso.createTextFile(OutputFile, True)


Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & str_boxname & "\root\default:StdRegProv")
strKeyPath   = "SOFTWARE\Microsoft\Microsoft SQL Server"
strValueName = "InstalledInstances"
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, bHasAccessRight
If bHasAccessRight = True Then
	ofile.writeline CHR(34)&"DBTYPE"&CHR(34)&"|"&CHR(34)&"DBNAME"&CHR(34)&"|"&CHR(34)&"VERSION"&CHR(34)&"|"&CHR(34)&"INSTANCENAME"&CHR(34)&"|"&CHR(34)&"SERVERNAME"&CHR(34)&"|"&CHR(34)&"INSTANCEIPS"&CHR(34)&"|"&CHR(34)&"PORT"&CHR(34)&"|"&CHR(34)&"DOMAIN"&CHR(34)&"|"&CHR(34)&"OS"&CHR(34)&"|"&CHR(34)&"OSVERSION"&CHR(34)&"|"&CHR(34)&"OSPATCHLEVEL"&CHR(34)&"|"&CHR(34)&"FDQN"&CHR(34)&"|"&CHR(34)&"IPS"&CHR(34)&"|"&CHR(34)&"CLUSTERINFO" &CHR(34) 

	oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrValues

	For Each RegInstanceName In arrValues
	    var_InstanceName = f_Instance(var_SERVERNAME,RegInstanceName)
	    var_Port = f_port(var_SERVERNAME, RegInstanceName )
	    var_Connection = f_connection(var_SERVERNAME,RegInstanceName )

		Set oServer = CreateObject("SQLDMO.SQLServer")
		oServer.LoginSecure = True
		if var_iscluster = 1 then
			oServer.Connect var_Connection & "," & var_port
		else
			oServer.Connect var_Connection
			var_CLUSTER = "no cluster info found"
		end if
		var_version = mid(oServer.VersionString,29,10)	
	
		
		For nDatabase = 1 to oServer.Databases.Count
		    ofile.writeline CHR(34) & "MSSQLSRV" & CHR(34) & "|" _ 
		    & CHR(34) & mid(Ucase(oServer.Databases(nDatabase).Name),1,32) & CHR(34) & "|" _ 	
		    & CHR(34) & var_version      & CHR(34) & "|" _	
		    & CHR(34) & Ucase(var_InstanceName) & CHR(34) & "|" _	
		    & CHR(34) & Ucase(var_SERVERNAME)   & CHR(34) & "|" _ 	
		    & CHR(34) & "*"   & CHR(34)    & "|" _						
		    & CHR(34) & var_Port & CHR(34) & "|" _
		    & CHR(34) & Ucase(var_Domain) & CHR(34) & "|" _					
		    & CHR(34) & Ucase(var_OS) & CHR(34) & "|" _					
		    & CHR(34) & var_OSVersion & CHR(34) & "|" _					
		    & CHR(34) & Ucase(var_OSSP) & CHR(34) & "|" _					
		    & CHR(34) & Ucase(var_FDQN) & CHR(34) & "|" _					
		    & CHR(34) & mid(var_IPS,1,128) & CHR(34) & "|" _	
			& CHR(34) & var_CLUSTER & CHR(34) 					
		    
		Next 
	    Set oServer = Nothing   			
	Next
Else
	ofile.writeline "NO_INSTANCE_FOUND"	
End If   

Set oFSO = Nothing

'---------------------------------------------------------------------------------------------------------------------
function f_Instance(strComputer, Installed_Instance)
	Const KEY_QUERY_VALUE = &H0001
	Const HKEY_LOCAL_MACHINE = &H80000002
	if Installed_Instance = "MSSQLSERVER" then
       	var_InstanceName = strComputer
		var_isCluster = 0
    else
		Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
		strKeyPath = "SOFTWARE\MICROSOFT\Microsoft SQL Server\" & Installed_Instance & "\Cluster"
		oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,bHasAccessRight
		If bHasAccessRight = True Then
		    oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, "ClusterName", strValue
		    var_InstanceName = strValue & "\" & Installed_Instance
		    var_isCluster = 1
		Else
		    var_InstanceName = strComputer & "\" & Installed_Instance
		    var_isCluster = 0
		End If   
   end if
   f_Instance = var_InstanceName
end function
'---------------------------------------------------------------------------------------------------------------------
'IPS
function f_IPS (strComputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True",,48) 
For Each objItem in colItems 
    If isNull(objItem.IPAddress) or trim(Join(objItem.IPAddress)) = "" or trim(Join(objItem.IPAddress)) = "0.0.0.0" Then
        var_IPS = var_IPS
    Else
        var_IPS = var_IPS & Join(objItem.IPAddress) & ","
    End If
        
Next
    f_IPS = mid(var_IPS,1,len(var_IPS)-1)
end function

'---------------------------------------------------------------------------------------------------------------------
'RETURNS FDQN
function f_FDQN (strComputer)
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
	Set colItems = objWMIService.ExecQuery( _
	    "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True ",,48) 
	For Each objItem in colItems
            if trim(objItem.DNSHostName) <> "" then 
	    	f_FDQN = objItem.DNSHostName
	    end if
	Next
end function

'---------------------------------------------------------------------------------------------------------------------
'RETURNS THE DOMAIN
function f_DOMAIN (strComputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48) 
For Each objItem in colItems 
    f_DOMAIN = objItem.Domain
Next
end function

'---------------------------------------------------------------------------------------------------------------------
'Returns the Operating System 
function f_OS(strcomputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_OperatingSystem",,48) 
For Each objItem in colItems 
    f_OS = objItem.Caption
Next
end function

'---------------------------------------------------------------------------------------------------------------------
'Returns the OS Version
function f_OSVersion(strcomputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_OperatingSystem",,48) 
For Each objItem in colItems 
    f_OSVersion = objItem.Version
Next
end function
'---------------------------------------------------------------------------------------------------------------------
function f_OSSP(strcomputer)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_OperatingSystem",,48) 
For Each objItem in colItems 
    f_OSSP = objItem.CSDVersion
Next
end function
'---------------------------------------------------------------------------------------------------------------------
'RETURNS THE SERVERNAME
function f_servername(strComputer)
	Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
	Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem",,48) 
	For Each objItem in colItems 
	    f_servername = objItem.Name
	Next
end function
'---------------------------------------------------------------------------------------------------------------------
'RETURNS THE CLUSTER NAME
function f_CLUSTER(strComputer)
	f_CLUSTER = ""
end function
'---------------------------------------------------------------------------------------------------------------------
'CONNECTION STRING 
function f_connection(strComputer, par_InstanceIp)
	Const KEY_QUERY_VALUE = &H0001
	Const HKEY_LOCAL_MACHINE = &H80000002
	var_connection = ""	

	if par_InstanceIp = "MSSQLSERVER" then
   	    var_connection = strComputer
    else
	    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
	    strKeyPath = "SOFTWARE\MICROSOFT\Microsoft SQL Server\" & par_InstanceIp & "\Cluster"
	    oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,bHasAccessRight
	    If bHasAccessRight = True Then
               f_instanceIp strComputer, par_instanceIp, var_connection
	    Else
    	       var_connection = strComputer & "\" & par_InstanceIp
	    End If   
   end if

   f_connection = var_connection
end function
'---------------------------------------------------------------------------------------------------------------------

'RETURNS THE PORT NUMBER
function f_port(strComputer,sInstance)
Const HKEY_LOCAL_MACHINE 	= &H80000002

	if sInstance = "MSSQLSERVER" THEN
    	sComputer = strComputer
        sKey		 = "SOFTWARE\MICROSOFT\MSSQLServer\MSSQLServer\Supersocketnetlib\Tcp"

	else
    	sComputer = strComputer
        instance  = sInstance
        sKey      = "SOFTWARE\MICROSOFT\Microsoft SQL Server\"+instance+"\MSSQLServer\Supersocketnetlib\Tcp"
    end if

sMethod		= "GetStringValue"
hTree		= HKEY_LOCAL_MACHINE
sValue		= "TcpPort"
Set oRegistry	 = GetObject("winmgmts:{impersonationLevel=impersonate}//"&sComputer&"/root/default:StdRegProv")
Set oMethod	     = oRegistry.Methods_(sMethod)
Set oInParam	 = oMethod.inParameters.SpawnInstance_()
oInParam.hDefKey = hTree
oInParam.sSubKeyName = sKey
oInParam.sValueName  = sValue
Set oOutParam        = oRegistry.ExecMethod_(sMethod, oInParam)
f_port = Cstr(oOutParam.Properties_("sValue"))
end function

'---------------------------------------------------------------------------------------------------------------------


function F_InstanceIP(strComputer, Installed_Instance, var_connection)
	Const KEY_QUERY_VALUE = &H0001
	Const HKEY_LOCAL_MACHINE = &H80000002
	var_connection = ""	

   Set oRegIp=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
   strKeyPathIp = "SOFTWARE\Microsoft\Microsoft SQL Server\" & Installed_Instance & "\Cluster" 
   oRegIp.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPathIp, "ClusterIpAddr", IParrValues

   For Each strValue In IParrValues
       var_connection = var_connection & strvalue
   Next
   set oRegIp = nothing
   f_instanceip = var_connection

end function
---------
]]></description>
			<content:encoded><![CDATA[<div>Hello,<br />
<br />
I am having a similar error and would like to ask why the script abandons and returns &quot;Object not in collection&quot;<br />
It's also writing out a text file.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">str_boxname = WScript.Arguments( 0 )<br />
<br />
const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
DIM var_IPS<br />
DIM var_Domain<br />
DIM var_SERVERNAME<br />
DIM var_VERSION<br />
DIM var_OS<br />
DIM var_OSVersion<br />
DIM var_OSSP<br />
DIM var_FDQN<br />
DIM var_InstanceName<br />
DIM var_port<br />
DIM var_connection<br />
DIM var_isCluster<br />
<br />
var_SERVERNAME&nbsp; &nbsp; &nbsp; &nbsp;  = f_servername(str_boxname)<br />
var_Domain&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  = f_DOMAIN(var_SERVERNAME)<br />
var_OS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  = f_OS(var_SERVERNAME)<br />
var_OSVersion&nbsp;  = f_OSVersion(var_SERVERNAME)<br />
var_OSSP&nbsp; &nbsp; &nbsp; &nbsp; = f_OSSP(var_SERVERNAME)<br />
var_IPS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  = f_IPS(var_SERVERNAME)<br />
var_FDQN&nbsp; &nbsp; &nbsp; &nbsp; = f_fdqn(var_SERVERNAME)<br />
var_CLUSTER&nbsp; &nbsp;  = f_CLUSTER(var_SERVERNAME)<br />
OutputFile=&quot;c:\temp\&quot; &amp; &quot;EPinventory.&quot; &amp; var_SERVERNAME <br />
Set oFSO = CreateObject(&quot;Scripting.FilesyStemObject&quot;)<br />
Set ofile = ofso.createTextFile(OutputFile, True)<br />
<br />
<br />
Set StdOut = WScript.StdOut<br />
Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; str_boxname &amp; &quot;\root\default:StdRegProv&quot;)<br />
strKeyPath&nbsp;  = &quot;SOFTWARE\Microsoft\Microsoft SQL Server&quot;<br />
strValueName = &quot;InstalledInstances&quot;<br />
oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE, bHasAccessRight<br />
If bHasAccessRight = True Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofile.writeline CHR(34)&amp;&quot;DBTYPE&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;DBNAME&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;VERSION&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;INSTANCENAME&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;SERVERNAME&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;INSTANCEIPS&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;PORT&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;DOMAIN&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;OS&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;OSVERSION&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;OSPATCHLEVEL&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;FDQN&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;IPS&quot;&amp;CHR(34)&amp;&quot;|&quot;&amp;CHR(34)&amp;&quot;CLUSTERINFO&quot; &amp;CHR(34) <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; oReg.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,arrValues<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; For Each RegInstanceName In arrValues<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_InstanceName = f_Instance(var_SERVERNAME,RegInstanceName)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_Port = f_port(var_SERVERNAME, RegInstanceName )<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_Connection = f_connection(var_SERVERNAME,RegInstanceName )<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set oServer = CreateObject(&quot;SQLDMO.SQLServer&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oServer.LoginSecure = True<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if var_iscluster = 1 then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oServer.Connect var_Connection &amp; &quot;,&quot; &amp; var_port<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oServer.Connect var_Connection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_CLUSTER = &quot;no cluster info found&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_version = mid(oServer.VersionString,29,10)&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For nDatabase = 1 to oServer.Databases.Count<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ofile.writeline CHR(34) &amp; &quot;MSSQLSRV&quot; &amp; CHR(34) &amp; &quot;|&quot; _ <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; mid(Ucase(oServer.Databases(nDatabase).Name),1,32) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; var_version&nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_InstanceName) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_SERVERNAME)&nbsp;  &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; &quot;*&quot;&nbsp;  &amp; CHR(34)&nbsp; &nbsp; &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; var_Port &amp; CHR(34) &amp; &quot;|&quot; _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_Domain) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_OS) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; var_OSVersion &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_OSSP) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; Ucase(var_FDQN) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; mid(var_IPS,1,128) &amp; CHR(34) &amp; &quot;|&quot; _&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp; CHR(34) &amp; var_CLUSTER &amp; CHR(34)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set oServer = Nothing&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; Next<br />
Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; ofile.writeline &quot;NO_INSTANCE_FOUND&quot;&nbsp; &nbsp; &nbsp; &nbsp; <br />
End If&nbsp;  <br />
<br />
Set oFSO = Nothing<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
function f_Instance(strComputer, Installed_Instance)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const KEY_QUERY_VALUE = &amp;H0001<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
&nbsp; &nbsp; &nbsp; &nbsp; if Installed_Instance = &quot;MSSQLSERVER&quot; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  var_InstanceName = strComputer<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_isCluster = 0<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\default:StdRegProv&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strKeyPath = &quot;SOFTWARE\MICROSOFT\Microsoft SQL Server\&quot; &amp; Installed_Instance &amp; &quot;\Cluster&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,bHasAccessRight<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If bHasAccessRight = True Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, strKeyPath, &quot;ClusterName&quot;, strValue<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_InstanceName = strValue &amp; &quot;\&quot; &amp; Installed_Instance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_isCluster = 1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_InstanceName = strComputer &amp; &quot;\&quot; &amp; Installed_Instance<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var_isCluster = 0<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If&nbsp;  <br />
&nbsp;  end if<br />
&nbsp;  f_Instance = var_InstanceName<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'IPS<br />
function f_IPS (strComputer)<br />
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &quot;SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True&quot;,,48) <br />
For Each objItem in colItems <br />
&nbsp; &nbsp; If isNull(objItem.IPAddress) or trim(Join(objItem.IPAddress)) = &quot;&quot; or trim(Join(objItem.IPAddress)) = &quot;0.0.0.0&quot; Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; var_IPS = var_IPS<br />
&nbsp; &nbsp; Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; var_IPS = var_IPS &amp; Join(objItem.IPAddress) &amp; &quot;,&quot;<br />
&nbsp; &nbsp; End If<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
Next<br />
&nbsp; &nbsp; f_IPS = mid(var_IPS,1,len(var_IPS)-1)<br />
end function<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'RETURNS FDQN<br />
function f_FDQN (strComputer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
&nbsp; &nbsp; &nbsp; &nbsp; Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True &quot;,,48) <br />
&nbsp; &nbsp; &nbsp; &nbsp; For Each objItem in colItems<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if trim(objItem.DNSHostName) &lt;&gt; &quot;&quot; then <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f_FDQN = objItem.DNSHostName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end if<br />
&nbsp; &nbsp; &nbsp; &nbsp; Next<br />
end function<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'RETURNS THE DOMAIN<br />
function f_DOMAIN (strComputer)<br />
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &quot;SELECT * FROM Win32_ComputerSystem&quot;,,48) <br />
For Each objItem in colItems <br />
&nbsp; &nbsp; f_DOMAIN = objItem.Domain<br />
Next<br />
end function<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'Returns the Operating System <br />
function f_OS(strcomputer)<br />
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &quot;SELECT * FROM Win32_OperatingSystem&quot;,,48) <br />
For Each objItem in colItems <br />
&nbsp; &nbsp; f_OS = objItem.Caption<br />
Next<br />
end function<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'Returns the OS Version<br />
function f_OSVersion(strcomputer)<br />
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &quot;SELECT * FROM Win32_OperatingSystem&quot;,,48) <br />
For Each objItem in colItems <br />
&nbsp; &nbsp; f_OSVersion = objItem.Version<br />
Next<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
function f_OSSP(strcomputer)<br />
Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
Set colItems = objWMIService.ExecQuery( _<br />
&nbsp; &nbsp; &quot;SELECT * FROM Win32_OperatingSystem&quot;,,48) <br />
For Each objItem in colItems <br />
&nbsp; &nbsp; f_OSSP = objItem.CSDVersion<br />
Next<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'RETURNS THE SERVERNAME<br />
function f_servername(strComputer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set objWMIService = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\CIMV2&quot;) <br />
&nbsp; &nbsp; &nbsp; &nbsp; Set colItems = objWMIService.ExecQuery(&quot;SELECT * FROM Win32_ComputerSystem&quot;,,48) <br />
&nbsp; &nbsp; &nbsp; &nbsp; For Each objItem in colItems <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f_servername = objItem.Name<br />
&nbsp; &nbsp; &nbsp; &nbsp; Next<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'RETURNS THE CLUSTER NAME<br />
function f_CLUSTER(strComputer)<br />
&nbsp; &nbsp; &nbsp; &nbsp; f_CLUSTER = &quot;&quot;<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
'CONNECTION STRING <br />
function f_connection(strComputer, par_InstanceIp)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const KEY_QUERY_VALUE = &amp;H0001<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
&nbsp; &nbsp; &nbsp; &nbsp; var_connection = &quot;&quot;&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if par_InstanceIp = &quot;MSSQLSERVER&quot; then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  var_connection = strComputer<br />
&nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set oReg=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\default:StdRegProv&quot;)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strKeyPath = &quot;SOFTWARE\MICROSOFT\Microsoft SQL Server\&quot; &amp; par_InstanceIp &amp; &quot;\Cluster&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oReg.CheckAccess HKEY_LOCAL_MACHINE, strKeyPath, KEY_QUERY_VALUE,bHasAccessRight<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If bHasAccessRight = True Then<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  f_instanceIp strComputer, par_instanceIp, var_connection<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  var_connection = strComputer &amp; &quot;\&quot; &amp; par_InstanceIp<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End If&nbsp;  <br />
&nbsp;  end if<br />
<br />
&nbsp;  f_connection = var_connection<br />
end function<br />
'---------------------------------------------------------------------------------------------------------------------<br />
<br />
'RETURNS THE PORT NUMBER<br />
function f_port(strComputer,sInstance)<br />
Const HKEY_LOCAL_MACHINE&nbsp; &nbsp; &nbsp; &nbsp;  = &amp;H80000002<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; if sInstance = &quot;MSSQLSERVER&quot; THEN<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sComputer = strComputer<br />
&nbsp; &nbsp; &nbsp; &nbsp; sKey&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  = &quot;SOFTWARE\MICROSOFT\MSSQLServer\MSSQLServer\Supersocketnetlib\Tcp&quot;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sComputer = strComputer<br />
&nbsp; &nbsp; &nbsp; &nbsp; instance&nbsp; = sInstance<br />
&nbsp; &nbsp; &nbsp; &nbsp; sKey&nbsp; &nbsp; &nbsp; = &quot;SOFTWARE\MICROSOFT\Microsoft SQL Server\&quot;+instance+&quot;\MSSQLServer\Supersocketnetlib\Tcp&quot;<br />
&nbsp; &nbsp; end if<br />
<br />
sMethod&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &quot;GetStringValue&quot;<br />
hTree&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = HKEY_LOCAL_MACHINE<br />
sValue&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = &quot;TcpPort&quot;<br />
Set oRegistry&nbsp; &nbsp; &nbsp; &nbsp;  = GetObject(&quot;winmgmts:{impersonationLevel=impersonate}//&quot;&amp;sComputer&amp;&quot;/root/default:StdRegProv&quot;)<br />
Set oMethod&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  = oRegistry.Methods_(sMethod)<br />
Set oInParam&nbsp; &nbsp; &nbsp; &nbsp;  = oMethod.inParameters.SpawnInstance_()<br />
oInParam.hDefKey = hTree<br />
oInParam.sSubKeyName = sKey<br />
oInParam.sValueName&nbsp; = sValue<br />
Set oOutParam&nbsp; &nbsp; &nbsp; &nbsp; = oRegistry.ExecMethod_(sMethod, oInParam)<br />
f_port = Cstr(oOutParam.Properties_(&quot;sValue&quot;))<br />
end function<br />
<br />
'---------------------------------------------------------------------------------------------------------------------<br />
<br />
<br />
function F_InstanceIP(strComputer, Installed_Instance, var_connection)<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const KEY_QUERY_VALUE = &amp;H0001<br />
&nbsp; &nbsp; &nbsp; &nbsp; Const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
&nbsp; &nbsp; &nbsp; &nbsp; var_connection = &quot;&quot;&nbsp; &nbsp; &nbsp; &nbsp; <br />
<br />
&nbsp;  Set oRegIp=GetObject(&quot;winmgmts:{impersonationLevel=impersonate}!\\&quot; &amp; strComputer &amp; &quot;\root\default:StdRegProv&quot;)<br />
&nbsp;  strKeyPathIp = &quot;SOFTWARE\Microsoft\Microsoft SQL Server\&quot; &amp; Installed_Instance &amp; &quot;\Cluster&quot; <br />
&nbsp;  oRegIp.GetMultiStringValue HKEY_LOCAL_MACHINE, strKeyPathIp, &quot;ClusterIpAddr&quot;, IParrValues<br />
<br />
&nbsp;  For Each strValue In IParrValues<br />
&nbsp; &nbsp; &nbsp;  var_connection = var_connection &amp; strvalue<br />
&nbsp;  Next<br />
&nbsp;  set oRegIp = nothing<br />
&nbsp;  f_instanceip = var_connection<br />
<br />
end function</code><hr />
</div></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>dave64leo</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?720961-Object-not-in-collection</guid>
		</item>
		<item>
			<title>New to VB and need a professionals assistance, please</title>
			<link>http://www.vbforums.com/showthread.php?720435-New-to-VB-and-need-a-professionals-assistance-please&amp;goto=newpost</link>
			<pubDate>Fri, 03 May 2013 22:02:08 GMT</pubDate>
			<description><![CDATA[Alright, I'll start at the beginning. 

I work for a small company, that uses software that is very poorly developed. I'm attempting to improve the workflow and capabilities of the system via VBS (and any other languages needed). I realize I stated I'm new, that however does not mean I do not know anything at all. I learn almost immediately and have an immense skill to understand anything I'm shown. I need someone to collaborate with me, essentially pointing out where I'm going wrong and where I can improve. If it seems like a tall order, let me say I'm willing to even pay for the help I recieve.

A little background:

I'm a Trumpf500 operator that is attempting to learn programming on the side. I have a decent knowledge of the ins and outs of programming. I had written a proof-of-concept script and a fellow worker had witnessed me using it. One conversation led to another, which led to speaking with our IT Devs, and then the main supervisor. After all the discussions I was given 1-2 months to come up with a working DEMO, not fully fleshed out program or anything too big, just a DEMO. Something that shows my idea and does what it needs to do.

The concept:

There is a program titled: ABC_Desktop we use to log our work. This software is slow, outdated (function wise not code), and open to errors as it relies solely on user input. I'm wanting to use VBScript, Html, xhtml, etc. to create a kind of "add-on" to the program. Something that runs alongside the program, essentially automating data input and helping to eliminate errors by reducing user input. 

I suppose you could say it would function as a virtual peripheral. Why am I attempting this when the company could spend money on other software or developers? Well, firstly because I'm passionate about computer programming, and secondly I am being offered a promotion and a raise if i can accomplish this goal.

So, is there anyone here that can/will help me?]]></description>
			<content:encoded><![CDATA[<div>Alright, I'll start at the beginning. <br />
<br />
I work for a small company, that uses software that is very poorly developed. I'm attempting to improve the workflow and capabilities of the system via VBS (and any other languages needed). I realize I stated I'm new, that however does not mean I do not know anything at all. I learn almost immediately and have an immense skill to understand anything I'm shown. I need someone to collaborate with me, essentially pointing out where I'm going wrong and where I can improve. If it seems like a tall order, let me say I'm willing to even pay for the help I recieve.<br />
<br />
A little background:<br />
<br />
I'm a Trumpf500 operator that is attempting to learn programming on the side. I have a decent knowledge of the ins and outs of programming. I had written a proof-of-concept script and a fellow worker had witnessed me using it. One conversation led to another, which led to speaking with our IT Devs, and then the main supervisor. After all the discussions I was given 1-2 months to come up with a working DEMO, not fully fleshed out program or anything too big, just a DEMO. Something that shows my idea and does what it needs to do.<br />
<br />
The concept:<br />
<br />
There is a program titled: ABC_Desktop we use to log our work. This software is slow, outdated (function wise not code), and open to errors as it relies solely on user input. I'm wanting to use VBScript, Html, xhtml, etc. to create a kind of &quot;add-on&quot; to the program. Something that runs alongside the program, essentially automating data input and helping to eliminate errors by reducing user input. <br />
<br />
I suppose you could say it would function as a virtual peripheral. Why am I attempting this when the company could spend money on other software or developers? Well, firstly because I'm passionate about computer programming, and secondly I am being offered a promotion and a raise if i can accomplish this goal.<br />
<br />
So, is there anyone here that can/will help me?</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>MemetoMori</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?720435-New-to-VB-and-need-a-professionals-assistance-please</guid>
		</item>
		<item>
			<title>weird characters showing up in html</title>
			<link>http://www.vbforums.com/showthread.php?720363-weird-characters-showing-up-in-html&amp;goto=newpost</link>
			<pubDate>Fri, 03 May 2013 14:12:13 GMT</pubDate>
			<description><![CDATA[I have a project that gets input from an xml file that we extract information from select nodes.

One of the does we take the info and just output in a <pre> tag since it's already formated from source.

We started seeing all these B's in the output so I ran a loop through all the characters and display the ascii value to see what it is and this is what I get in return.

How I get value:

Code:
---------
For x=1 To Len(str)
	result = result & Mid(str, x, 1) & "(" & Asc(Mid(str, x, 1)) & ")"
Next
---------
Result for the character in question:
&#1042; (-15712)

Any ideas how I can strip these out?

Thanks.]]></description>
			<content:encoded><![CDATA[<div>I have a project that gets input from an xml file that we extract information from select nodes.<br />
<br />
One of the does we take the info and just output in a &lt;pre&gt; tag since it's already formated from source.<br />
<br />
We started seeing all these B's in the output so I ran a loop through all the characters and display the ascii value to see what it is and this is what I get in return.<br />
<br />
How I get value:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">For x=1 To Len(str)<br />
&nbsp; &nbsp; &nbsp; &nbsp; result = result &amp; Mid(str, x, 1) &amp; &quot;(&quot; &amp; Asc(Mid(str, x, 1)) &amp; &quot;)&quot;<br />
Next</code><hr />
</div>Result for the character in question:<br />
&#1042; (-15712)<br />
<br />
Any ideas how I can strip these out?<br />
<br />
Thanks.</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>lleemon</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?720363-weird-characters-showing-up-in-html</guid>
		</item>
		<item>
			<title>assigning some elements in an array to another array... Please Help</title>
			<link>http://www.vbforums.com/showthread.php?720271-assigning-some-elements-in-an-array-to-another-array-Please-Help&amp;goto=newpost</link>
			<pubDate>Thu, 02 May 2013 19:32:44 GMT</pubDate>
			<description><![CDATA[I'm hoping this is a stupid question that can be answered rather quickly and easily.

So here what I'm trying to do. I want to take a 1 dimensional array that is already full and pass it through a for loop and when ever there is a match to my if statement.
It will copy that element out of the array and put it in a new array.

Here is a example of my code:

Public GlobalArray() As String

Dim aryText() As String
aryText = Inputfile     <----- This is where the live rile was passed to the array

Dim newstr_count As Integer = UBound(aryText)

For z = 0 To newstr_count - 1

If aryText(z).Trim = "copy I'm looking to extract from the array"

GlobalArray = (aryText(z), z) '<------- Here is where I can't figure out how to pass the elements I want to keep to another array

z = z + 1
End if

next z

Thank you in advance for your help!
Chris]]></description>
			<content:encoded><![CDATA[<div>I'm hoping this is a stupid question that can be answered rather quickly and easily.<br />
<br />
So here what I'm trying to do. I want to take a 1 dimensional array that is already full and pass it through a for loop and when ever there is a match to my if statement.<br />
It will copy that element out of the array and put it in a new array.<br />
<br />
Here is a example of my code:<br />
<br />
Public GlobalArray() As String<br />
<br />
Dim aryText() As String<br />
aryText = Inputfile     &lt;----- This is where the live rile was passed to the array<br />
<br />
Dim newstr_count As Integer = UBound(aryText)<br />
<br />
For z = 0 To newstr_count - 1<br />
<br />
If aryText(z).Trim = &quot;copy I'm looking to extract from the array&quot;<br />
<br />
GlobalArray = (aryText(z), z) '&lt;------- Here is where I can't figure out how to pass the elements I want to keep to another array<br />
<br />
z = z + 1<br />
End if<br />
<br />
next z<br />
<br />
Thank you in advance for your help!<br />
Chris</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>brtm5</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?720271-assigning-some-elements-in-an-array-to-another-array-Please-Help</guid>
		</item>
		<item>
			<title><![CDATA[[RESOLVED] visual basic script]]></title>
			<link>http://www.vbforums.com/showthread.php?719967-RESOLVED-visual-basic-script&amp;goto=newpost</link>
			<pubDate>Tue, 30 Apr 2013 12:36:01 GMT</pubDate>
			<description><![CDATA[Hi, can somone help me? I have script and i dont know what is wrong:

Function LastRow()
Dim c As Object
With Sheets(1).Range("A:A")
Set c = .Find(What:="*", LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)
End With
LastRow = (c.Row)
End Function

Function inserthgbstelement(title, status, rank)
    Dim funObjid As Long
    objName = "hgbst_elm"
    funObjid = getNextObjid(objName)
    
    conn.Execute "insert into table_hgbst_elm(objid, TITLE, S_TITLE, RANK, STATE, DEV, INTVAL) values (funObjid, title, Upper(title), rank, status, "",0)"
    inserthgbstelement = funObjid
End Function


Sub Przeszukanie_po_wierszu()

Dim c As Object
Dim x As Integer


With Sheets(1).Range("A:A")
Set c = .Find(What:="*", LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByColumns, searchdirection:=xlPrevious)
For x = 3 To LastRow
y = inserthgbstelement(Sheets(1).Range("A" + x), Sheets(1).Range("B" + x), x - 3)
Next x
End With
End Sub



Error: 13   type mismatch
if i click on debyg show me line                y = inserthgbstelement(Sheets(1).Range("A" + x), Sheets(1).Range("B" + x), x - 3)]]></description>
			<content:encoded><![CDATA[<div>Hi, can somone help me? I have script and i dont know what is wrong:<br />
<br />
Function LastRow()<br />
Dim c As Object<br />
With Sheets(1).Range(&quot;A:A&quot;)<br />
Set c = .Find(What:=&quot;*&quot;, LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)<br />
End With<br />
LastRow = (c.Row)<br />
End Function<br />
<br />
Function inserthgbstelement(title, status, rank)<br />
    Dim funObjid As Long<br />
    objName = &quot;hgbst_elm&quot;<br />
    funObjid = getNextObjid(objName)<br />
    <br />
    conn.Execute &quot;insert into table_hgbst_elm(objid, TITLE, S_TITLE, RANK, STATE, DEV, INTVAL) values (funObjid, title, Upper(title), rank, status, &quot;&quot;,0)&quot;<br />
    inserthgbstelement = funObjid<br />
End Function<br />
<br />
<br />
Sub Przeszukanie_po_wierszu()<br />
<br />
Dim c As Object<br />
Dim x As Integer<br />
<br />
<br />
With Sheets(1).Range(&quot;A:A&quot;)<br />
Set c = .Find(What:=&quot;*&quot;, LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByColumns, searchdirection:=xlPrevious)<br />
For x = 3 To LastRow<br />
y = inserthgbstelement(Sheets(1).Range(&quot;A&quot; + x), Sheets(1).Range(&quot;B&quot; + x), x - 3)<br />
Next x<br />
End With<br />
End Sub<br />
<br />
<br />
<br />
Error: 13   type mismatch<br />
if i click on debyg show me line                y = inserthgbstelement(Sheets(1).Range(&quot;A&quot; + x), Sheets(1).Range(&quot;B&quot; + x), x - 3)</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>kaczak1108</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?719967-RESOLVED-visual-basic-script</guid>
		</item>
		<item>
			<title>Detect Table Overlap</title>
			<link>http://www.vbforums.com/showthread.php?719545-Detect-Table-Overlap&amp;goto=newpost</link>
			<pubDate>Sat, 27 Apr 2013 02:12:19 GMT</pubDate>
			<description><![CDATA[Hey there,
I'm writing an app that automatically creates a PivotTable.

I've got everything working, except that I want the PivotTables to all appear on the same sheet. Often, users will be performing actions that cause the pivottables' row count to go up and down. I've been asked to make the PivotTables have a 2-row buffer between them. I just need a way to detect if a PivotTable has overlapped another. I've got the code working that moves them up and down by row and column number, or by a  difference (i.e. movePivotTableDownBy(2).).
 Ideally, there would be an Excel Overlap function that would tell my how much the overlap was so I could move the remaining tables to where they need to be.

As this sheet evolves, I'd like to take into account having more than three PivotTables. Right now I'm at three. 

So it would look something like this, I'd think:

Code:
---------
For each pt in pivottables
     get the top and the bottom
     is there already (a table with bottom>pt.top) OR (a table with top<pt.bottom)    <---- THIS IS WHAT I NEED
        if so, move pt.(top or bottom) +- (the table with bottom/top) +- 2 
Next x
---------
Any ideas on the data structure for that? I've thought of some kind of variant dictionary, but I'm having a hard time seeing beyond a linear iteration. I'm thinking some kind of hash table, but the problem remains - what do I do to detect if there is a "table collision" without iterating through each entry in a collection, array, etc. and then back through it with each new entry. Some kind of insertion sort on the tops and iteration through the bottoms maybe? Even that seems too complicated.

Anyone got anything?]]></description>
			<content:encoded><![CDATA[<div>Hey there,<br />
I'm writing an app that automatically creates a PivotTable.<br />
<br />
I've got everything working, except that I want the PivotTables to all appear on the same sheet. Often, users will be performing actions that cause the pivottables' row count to go up and down. I've been asked to make the PivotTables have a 2-row buffer between them. I just need a way to detect if a PivotTable has overlapped another. I've got the code working that moves them up and down by row and column number, or by a  difference (i.e. movePivotTableDownBy(2).).<br />
 Ideally, there would be an Excel Overlap function that would tell my how much the overlap was so I could move the remaining tables to where they need to be.<br />
<br />
As this sheet evolves, I'd like to take into account having more than three PivotTables. Right now I'm at three. <br />
<br />
So it would look something like this, I'd think:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<hr /><code class="bbcode_code">For each pt in pivottables<br />
&nbsp; &nbsp;  get the top and the bottom<br />
&nbsp; &nbsp;  is there already (a table with bottom&gt;pt.top) OR (a table with top&lt;pt.bottom)&nbsp; &nbsp; &lt;---- THIS IS WHAT I NEED<br />
&nbsp; &nbsp; &nbsp; &nbsp; if so, move pt.(top or bottom) +- (the table with bottom/top) +- 2 <br />
Next x</code><hr />
</div>Any ideas on the data structure for that? I've thought of some kind of variant dictionary, but I'm having a hard time seeing beyond a linear iteration. I'm thinking some kind of hash table, but the problem remains - what do I do to detect if there is a &quot;table collision&quot; without iterating through each entry in a collection, array, etc. and then back through it with each new entry. Some kind of insertion sort on the tops and iteration through the bottoms maybe? Even that seems too complicated.<br />
<br />
Anyone got anything?</div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>drag0n_45</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?719545-Detect-Table-Overlap</guid>
		</item>
		<item>
			<title>Empty Reg MultiString</title>
			<link>http://www.vbforums.com/showthread.php?719369-Empty-Reg-MultiString&amp;goto=newpost</link>
			<pubDate>Thu, 25 Apr 2013 19:55:28 GMT</pubDate>
			<description><![CDATA[So, I want to check a REG_MULTI_SZ in a key and if it is empty then do something. However, my script keeps reporting that it contains data when it does not. Whats wrong?

*
Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\HP Universal Printing PCL 5 (v5.4)"
strValueName = "Dependent Files"
objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue,arrValues

If IsNull(arrValues) Then
    Wscript.Echo "Empty."
Else
	Wscript.Echo "The value contains data."
End If
*]]></description>
			<content:encoded><![CDATA[<div>So, I want to check a REG_MULTI_SZ in a key and if it is empty then do something. However, my script keeps reporting that it contains data when it does not. Whats wrong?<br />
<br />
<span class="highlight"><br />
Const HKEY_LOCAL_MACHINE = &amp;H80000002<br />
<br />
strComputer = &quot;.&quot;<br />
Set objRegistry = GetObject(&quot;winmgmts:\\&quot; &amp; strComputer &amp; &quot;\root\default:StdRegProv&quot;)<br />
 <br />
strKeyPath = &quot;SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\Version-3\HP Universal Printing PCL 5 (v5.4)&quot;<br />
strValueName = &quot;Dependent Files&quot;<br />
objRegistry.GetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue,arrValues<br />
<br />
If IsNull(arrValues) Then<br />
    Wscript.Echo &quot;Empty.&quot;<br />
Else<br />
	Wscript.Echo &quot;The value contains data.&quot;<br />
End If<br />
</span></div>

]]></content:encoded>
			<category domain="http://www.vbforums.com/forumdisplay.php?4-ASP-VB-Script">ASP, VB Script</category>
			<dc:creator>William_D</dc:creator>
			<guid isPermaLink="true">http://www.vbforums.com/showthread.php?719369-Empty-Reg-MultiString</guid>
		</item>
	</channel>
</rss>
