Hallo
Ich habe ein VBScript in Visual Basic umgewandelt.
Das Problem ist jetzt, dass wenn ich ein Arrayliste mache und dann in die For Each schleife einbinde, funktionirt das nicht.
Hoffe ihr könnt mir helfen.
Gruss
Visual Basic Code:
Spoiler anzeigen
VBScript
Spoiler anzeigen
Ich habe ein VBScript in Visual Basic umgewandelt.
Das Problem ist jetzt, dass wenn ich ein Arrayliste mache und dann in die For Each schleife einbinde, funktionirt das nicht.
Hoffe ihr könnt mir helfen.
Gruss
Visual Basic Code:
Visual Basic-Quellcode
- Dim strinputFile As String = eingegebenetags
- Dim strOutputFile As String = ""
- Dim strDetails As String = ""
- Dim strCurrentTag As String = ""
- Dim strurl As String = "http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?c=in&cs=inbsd1&l=en&s=bsd&ServiceTag=" & strServiceTag & "&~tab=1"
- Dim webClient As System.Net.WebClient = New System.Net.WebClient()
- Dim results As String
- Dim startpage As String
- Dim arraylist As List(Of String) 'arrheadings = Array("Service Tag:", "Days Left") <---- Das ist der VBScript Code
- arraylist.Add("Service Tag:")
- arraylist.Add("Days Left")
- Const intForReading = 1
- results = webClient.DownloadString(strurl)
- For Each strHeading In arraylist
- intSummaryPos = InStr(LCase(strPageText), LCase(strHeading))
- If intSummaryPos > 0 Then
- intSummaryTableStart = InStrRev(LCase(strPageText), "<table", intSummaryPos)
- intSummaryTableEnd = InStr(intSummaryPos, LCase(strPageText), "</table>") + 8
- strInfoTable = Mid(strPageText, intSummaryTableStart, intSummaryTableEnd - intSummaryTableStart)
- strInfoTable = Replace(Replace(Replace(strInfoTable, vbCrLf, ""), vbCr, ""), vbLf, "")
- arrCells = Split(LCase(strInfoTable), "</td>")
- For intCell = LBound(arrCells) To UBound(arrCells)
- arrCells(intCell) = Trim(arrCells(intCell))
- intOpenTag = InStr(arrCells(intCell), "<")
- While intOpenTag > 0
- intCloseTag = InStr(intOpenTag, arrCells(intCell), ">") + 1
- strNewCell = ""
- If intOpenTag > 1 Then strNewCell = strNewCell & Trim(Left(arrCells(intCell), intOpenTag - 1))
- If intCloseTag < Len(arrCells(intCell)) Then strNewCell = strNewCell & Trim(Mid(arrCells(intCell), intCloseTag))
- arrCells(intCell) = Replace(Trim(strNewCell), " change service tag", "")
- intOpenTag = InStr(arrCells(intCell), "<")
- End While
- Next
- 'WScript.Echo Join(arrCells, "|")
- If LCase(arrCells(0)) = LCase("Service Tag:") Then
- 'strCurrentTag = """" & strServiceTag & """"
- strCurrentTag = ""
- For intField = 1 To UBound(arrCells) Step 2
- If strCurrentTag = "" Then
- strCurrentTag = " " & arrCells(intField) & " "
- Else
- strCurrentTag = strCurrentTag & ";" & arrCells(intField) & ""
- End If
- Next
- ElseIf LCase(arrCells(0)) = LCase("Description") Then
- For intField = 5 To UBound(arrCells)
- strCurrentTag = strCurrentTag & ";" & arrCells(intField) & ""
- Next
- End If
- Else
- strCurrentTag = """" & strServiceTag & """ ""No warranty information found."""
- End If
- Next
- strDetails = strDetails & strCurrentTag & vbCrLf & "#"
- strOutputFile = strDetails
VBScript
Quellcode
- strInputFile = "DellServiceTags.txt"
- strOutputFile = "Results.csv"
- arrHeadings = Array("Service Tag:", "Days Left")
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Const intForReading = 1
- Set objHTTP = CreateObject("MSXML2.serverXMLHTTP")
- 'strDetails = """Service Tag"",""System Type"",""Ship Date"",""Dell IBU"",""Description"",""Provider"",""Start Date"",""End Date"",""Days Left"""
- Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
- While Not objInputFile.AtEndOfStream
- strServiceTag = objInputFile.ReadLine
- strCurrentTag = ""
- strURL = "http://www.dell.com/support/troubleshooting/in/en/inbsd1/Index?c=in&l=en&s=bsd&cs=inbsd1&t=warranty&servicetag=DR8W55J"
- objHTTP.open "GET", strURL, False
- objHTTP.send
- strPageText = objHTTP.responseText
- For Each strHeading In arrHeadings
- intSummaryPos = InStr(LCase(strPageText), LCase(strHeading))
- If intSummaryPos > 0 Then
- intSummaryTableStart = InStrRev(LCase(strPageText), "<table", intSummaryPos)
- intSummaryTableEnd = InStr(intSummaryPos, LCase(strPageText), "</table>") + 8
- MsgBox intSummaryTableEnd
- MsgBox intSummaryTableStart
- strInfoTable = Mid(strPageText, intSummaryTableStart, intSummaryTableEnd - intSummaryTableStart)
- strInfoTable = Replace(Replace(Replace(strInfoTable, VbCrLf, ""), vbCr, ""), vbLf, "")
- arrCells = Split(LCase(strInfoTable), "</td>")
- For intCell = LBound(arrCells) To UBound(arrCells)
- arrCells(intCell) = Trim(arrCells(intCell))
- intOpenTag = InStr(arrCells(intCell), "<")
- While intOpenTag > 0
- intCloseTag = InStr(intOpenTag, arrCells(intCell), ">") + 1
- strNewCell = ""
- If intOpenTag > 1 Then strNewCell = strNewCell & Trim(Left(arrCells(intCell), intOpenTag - 1))
- If intCloseTag < Len(arrCells(intCell)) Then strNewCell = strNewCell & Trim(Mid(arrCells(intCell), intCloseTag))
- arrCells(intCell) = Replace(Trim(strNewCell), " change service tag","")
- intOpenTag = InStr(arrCells(intCell), "<")
- Wend
- Next
- 'WScript.Echo Join(arrCells, "|")
- If LCase(arrCells(0)) = LCase("Service Tag:") Then
- 'strCurrentTag = """" & strServiceTag & """"
- strCurrentTag = ""
- For intField = 1 To UBound(arrCells) Step 2
- If strCurrentTag = "" Then
- strCurrentTag = " " & arrCells(intField) & " "
- Else
- strCurrentTag = strCurrentTag & ";" & arrCells(intField) & ""
- End If
- Next
- ElseIf LCase(arrCells(0)) = LCase("Description") Then
- For intField = 5 To UBound(arrCells)
- strCurrentTag = strCurrentTag & ";" & arrCells(intField) & ""
- Next
- End If
- Else
- strCurrentTag = """" & strServiceTag & """ ""No warranty information found."""
- End If
- Next
- strDetails = strDetails & strCurrentTag & Vbcrlf & "#"
- Wend
- objInputFile.Close
- Set objInputFile = Nothing
- Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
- objOutputFile.Write strDetails
- objOutputFile.Close
- Set objOutputFile = Nothing
- Set objFSO = Nothing
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „dungons“ ()