Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading IP Address from CSV File will not pull full IP Address

Status
Not open for further replies.

jjason01

Programmer
Jul 7, 2010
7
US
I have a CSV file with a printer name, printer ip address, and printer type. I am using vbscript in a hta to read the csv file and put it in a list box. I can get it to work fine but the ip address does not all come up. If I have a IP of 10.20.34.5 it shows up as 10.20 and that's it. My code is below.

''''Setup connection to txt file to read in files
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
strPathtoTextFile = objShell.CurrentDirectory

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""

objRecordset.Open "SELECT * FROM " & onloadfilename, _
objConnection, adOpenStatic, adLockOptimistic, adCmdText

''''Reads txt file and inputs into drop down box
For Each objOption in PrinterList.Options
objOption.RemoveNode
Next

Do Until objRecordset.EOF
strLine = objRecordset.Fields.Item("PrinterName") & " - " & objRecordset.Fields.Item("IPAddress") & " - " & objRecordset.Fields.Item("PrinterInstalled")
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
PrinterList.Add(objOption)
objRecordset.MoveNext
Loop
objRecordset.Close
objConnection.Close
 
In the CSV file, put double quotes around the ip addresses.
 
Ok so it shows up but with the quotes in my list box? Do I need to just remove them in code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top