[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/13/2009 at 04:05PM PDT, ID: 24809647
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

Convert VBS to VB.net/VB 2008

Asked by jcamping in VB Script, Visual Basic Programming, .NET

Tags: HP, Warranty, check, vbs, vb.net

I need the attached VBS converted to VB.NET or VB 2008. Any takers?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
'=========================
' Get_Warranty_Info_On_HP_Equipment_From_Service_Tag.vbs
' http://www.experts-exchange.com/Programming/Languages/Q_23097377.html
 
strInputFile = "HPSerialNumbers.txt"
strOutputFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "Results.csv"
 
arrTextToSearchFor = Array("Warranty Type","HWM Onsite")
 
arrJoinFields = Array("Serial Number","Product Number","Product Description","Date of Warranty Check","Warranty Type","Start Date","HP Care Pack Serial Number","HWM Onsite","Status","End Date","Service Level","Deliverables","6-Hour, 24x7, Call-To-Repair, HW Support","Wty: HP HW Maintenance Onsite Support","Wty: HP Support for Initial Setup")
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
 
strDetails = """WARRANTY INFORMATION"""
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
While Not objInputFile.AtEndOfStream
      arrLine = Split(objInputFile.ReadLine, ";")
      strProductNumber = arrLine(0)
      strSerialNumber = arrLine(1)
      strURL = "http://www11.itrc.hp.com/service/ewarranty/warrantyResults.do?BODServiceID=NA&serialNumber10=&RegisteredPurchaseDate=&y=11&x=26&serialNumber4=&country=IN&serialNumber9=&serialNumber5=&serialNumber6=&serialNumber7=&serialNumber8=&serialNumber1=" & strSerialNumber & "&serialNumber2=&serialNumber3=&productNumber=" & strProductNumber & "&hpweb_printable=true"
      Set objIE = CreateObject("InternetExplorer.Application")
      objIE.Visible = True
      objIE.Navigate strURL
      While objIE.ReadyState <> 4
            WScript.Sleep 100
      Wend
      
      strPageText = objIE.Document.Body.InnerHTML
      'WScript.Echo strPageText
 
      ' Reset the text for the current product
      strCurrentProduct = ""
 
      For Each strSearchText In arrTextToSearchFor
            intSummaryPos = InStr(LCase(strPageText), LCase(strSearchText))
            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, "")
                  strInfoTable = Replace(strInfoTable, "<BR>", VbLf)
                  'WScript.Echo strInfoTable
                  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) = Trim(strNewCell)
                              intOpenTag = InStr(arrCells(intCell), "<")
                        Wend
                  Next
                  'WScript.Echo Join(arrCells, "|")
                  strCurrentProduct = strCurrentProduct & Join(arrCells, "|")
                  strCurrentProduct = Replace(strCurrentProduct, "||", "|")
                  'strCurrentProduct = Replace(Replace(Replace(strCurrentProduct, "||", "|"), VbCrLf & "|", "|"), "|" & VbCrLf, "|")
                  If Left(strCurrentProduct, 1) = "|" Then strCurrentProduct = Right(strCurrentProduct, Len(strCurrentProduct) - 1)
                  If Right(strCurrentProduct, 1) = "|" Then strCurrentProduct = Left(strCurrentProduct, Len(strCurrentProduct) - 1)
                  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
      'WScript.Echo strCurrentProduct
      If InStr(strCurrentProduct, "hpcare pack serial numberhpcare pack serial number") > 0 Then _
            strCurrentProduct = Replace(strCurrentProduct, "hpcare pack serial numberhpcare pack serial number", "hp care pack serial number")
      arrCells = Split(strCurrentProduct, "|")
      strJoinFields = ";" & Join(arrJoinFields, ";") & ";"
      For Each strCell In arrCells
            strCell = ProperCase_Words(strCell)
            If InStr(LCase(strJoinFields), ";" & LCase(strCell) & ";") > 0 Then
                  strDetails = strDetails & VbCrLf & """" & strCell & """"
            Else
                  'strDetails = Left(strDetails, Len(strDetails) - 1) & ": " & strCell & """"
                  strDetails = Left(strDetails, Len(strDetails) - 1) & """,""" & strCell & """"
            End If
      Next
      strDetails = strDetails & VbCrLf & VbCrLf & "==========================" & VbCrLf
      objIE.Quit
Wend
objInputFile.Close
Set objInputFile = Nothing
 
Set objOutputFile = objFSO.CreateTextFile(strOutputFile, True)
objOutputFile.Write strDetails
objOutputFile.Close
Set objOutputFile = Nothing
Set objFSO = Nothing
 
Set objShell = CreateObject("WScript.Shell")
objShell.Run """" & strOutputFile & """", 1, False
'MsgBox "Done. Please see " & strOutputFile
 
Function ProperCase_Words(strText)
      If IsNumeric(Left(strText, 1)) = False Then
            strText = UCase(Left(strText, 1)) & Mid(strText, 2)
      End If
 
      intPos = InStr(strText, " ")
      Do
            If IsNumeric(Mid(strText, intPos + 1, 1)) = False Then
                  strText = Left(strText, intPos) & UCase(Mid(strText, intPos + 1, 1)) & Mid(strText, intPos + 2)
            End If
            intPos = InStr(intPos + 1, strText, " ")
            If intPos > Len(strText) - 1 Then Exit Do
      Loop While intPos > 0
 
      ProperCase_Words = strText
End Function
'=========================
[+][-]10/14/09 05:15 AM, ID: 25569578

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/14/09 06:50 AM, ID: 25570424

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/14/09 08:17 AM, ID: 25571527

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/14/09 08:20 AM, ID: 25571556

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: VB Script, Visual Basic Programming, .NET
Tags: HP, Warranty, check, vbs, vb.net
Sign Up Now!
Solution Provided By: TheLearnedOne
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10/14/09 09:14 AM, ID: 25572176

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/14/09 09:27 AM, ID: 25572328

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625