需要VB脚本帮助 [英] VB script help needed
问题描述
大家好,
我是vb脚本的新手,并试图从中获取一些东西。我有一个读取现有表的脚本,从第二列获取参数(Firs colum是序号),然后使用info填充另一个colulm。现在我的问题是:要求脚本读取表格的代码是什么,例如从第10-20行读取某个行号。
有人可以帮助我吗?
提前致谢
大家好,
我是新手编写脚本并尝试从中获取内容。我有一个读取现有表的脚本,从第二列获取参数(Firs colum是序号),然后使用info填充另一个colulm。现在我的问题是:要求脚本读取表格的代码是什么,例如从第10-20行读取某个行号。
有人可以帮助我吗?
提前付款
什么样的表格我们在这里谈论吗? Excel?
什么样的表格我们在这里谈论吗? Excel中?
这是一个访问2002表。我想做的是 - 我有一张带有ip号码的桌子。我运行我的脚本,逐行读取该表,并将信息从WMI填充到表中。我所看到的是阅读某些记录,例如:10-20。
这里是脚本....
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
设置objConnection = CreateObject(" ADODB.Connection")
设置objRecordset = CreateObject(" ADODB.Recordset")
objConnection.Open" DSN = test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open" SELECT * FROM tbl_inventory" ,objConnection,_
adOpenStatic,adLockOptimistic
''objRecordSet.MoveFirst
Do while not objRecordSet.EOF
strComputer = objRecordSet(" ComputerIP")
''*************************** ********************** ***********************
设置objShell = CreateObject(" WScript.Shell")
strCommand ="%comspec%/ c ping -n 3 -w 1000" &安培;计算机与计算机"
设置objExecObject = objShell.Exec(strCommand)
strText = objExecobject.StdOut.ReadAll()
IF Instr(strText ,回复)> 0然后
''************************************** *********** *****************************
设置objWMIService = GetObject (" winmgmts:"&" {impersonationLevel = impersonate}!\\"& strComputer&" \root \ cimv2")
''此处添加条件---如果连接是通过以下代码执行,则跳至.MOVENEXT
如果Err.Number<> 0然后
objRecordSet(" Status")=" Not Accessable"''Err.Description
Err.Clear
Else
设置colSettings = objWMIService.ExecQuery(" Select * from Win32_Bios")
strComplete =" Active on:" &安培;日期& "在 &安培;时间
对于colSettings中的每个objsetting
''objRecordset.AddNew
objRecordSet(" ComputerIP")= strComputer
objRecordSet(" Status")= strComplete
objRecordSet(" SerialNumber")= objsetting.SerialNumber
objRecordSet(" Manufacturer")= objsetting.Manufacturer
objRecordset.Update
下一页
设置colSettings = objWMIService.ExecQuery(" Select * from Win32_ComputerSystem")
对于colSettings中的每个objsetting
objRecordSet(" ModelNumber")= objsetting.Model
objRecordset(" HostName")= objsetting。姓名
objRecordset(" UserName")= objsetting.UserName
objRecordset.Update
下一页
''结束条件在这里---结束如果
结束如果
''************** ******************************* *************** **** *******
Else
objRecordSet(" Status")=" Not Online"
结束如果
objRecordSet.MoveNext
循环
objrecordse.close
objconnection.close
这是一个访问2002表。我想做的是 - 我有一张带有ip号码的桌子。我运行我的脚本,逐行读取该表,并将信息从WMI填充到表中。我所看到的是阅读某些记录,例如:10-20。
这里是脚本....
我怀疑你需要的只是SELECT语句中的WHERE子句,但是你可以扩展记录10到20的意思吗?你是说你想从头开始跳过前9个记录,然后处理下10个记录吗?或者是10。在您的某个字段中的实际值?
Hi everyone,
I am a novice in vb scripting and trying to get something from it. I have a scripts that read an existing table, take the argument from 2nd column ( Firs colum is sequential number) and then populate the other colulm with info. Now my question: what would be the code to ask the scripts to read the table read the certain row number for example from row 10-20.
Could someone pls help me?
Thanks in advance
Hi everyone,
I am a novice in vb scripting and trying to get something from it. I have a scripts that read an existing table, take the argument from 2nd column ( Firs colum is sequential number) and then populate the other colulm with info. Now my question: what would be the code to ask the scripts to read the table read the certain row number for example from row 10-20.
Could someone pls help me?
Thanks in advanceWhat kind of "tables" are we talking about here? Excel?
What kind of "tables" are we talking about here? Excel?This is a access 2002 table. what i am trying to do is-- I have a table with ip number. I run my scripts which read that table line by line and populate info from WMI into the table. What I am lookin is to read certain record eg: from 10-20.
here is the scripts....
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=test;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM tbl_inventory" , objConnection, _
adOpenStatic, adLockOptimistic
''objRecordSet.MoveFirst
Do While Not objRecordSet.EOF
strComputer = objRecordSet("ComputerIP")
''************************************************* ***********************
Set objShell = CreateObject("WScript.Shell")
strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & ""
Set objExecObject = objShell.Exec(strCommand)
strText = objExecobject.StdOut.ReadAll()
IF Instr(strText, "Reply") > 0 Then
''************************************************* ***************************
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer& "\root\cimv2")
''ADD CONDITION HERE --- IF CONNECTION IS MADE THEN DO CODE BELOW OTHERWISE SKIP TO .MOVENEXT
If Err.Number <> 0 Then
objRecordSet("Status") = "Not Accessable"''Err.Description
Err.Clear
Else
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_Bios")
strComplete = "Active on: " & Date & " at " & time
For Each objsetting in colSettings
''objRecordset.AddNew
objRecordSet("ComputerIP") = strComputer
objRecordSet("Status") = strComplete
objRecordSet("SerialNumber") = objsetting.SerialNumber
objRecordSet("Manufacturer") = objsetting.Manufacturer
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objsetting in colSettings
objRecordSet("ModelNumber") = objsetting.Model
objRecordset("HostName") = objsetting.Name
objRecordset("UserName") = objsetting.UserName
objRecordset.Update
Next
''END CONDITION HERE --- END IF
End if
''************************************************* **************************
Else
objRecordSet("Status") = "Not Online"
End if
objRecordSet.MoveNext
Loop
objrecordse.close
objconnection.close
This is a access 2002 table. what i am trying to do is-- I have a table with ip number. I run my scripts which read that table line by line and populate info from WMI into the table. What I am lookin is to read certain record eg: from 10-20.
here is the scripts....I suspect that all you need is a WHERE clause in your SELECT statement, but can you expand on what you mean by records 10 to 20? Do you just mean that starting from the beginning you want to skip the first 9 records, then process the next 10? Or is that "10" and so on an actual value in one of your fields?
这篇关于需要VB脚本帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!