Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Go Back  Xtreme Visual Basic Talk > > > Conversion from string "Location" to type 'Integer' is not valid


Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2015, 02:49 PM
HappyJoni's Avatar
HappyJoni HappyJoni is offline
Centurion
 
Join Date: Jun 2003
Location: New Jersey
Posts: 169
Question Conversion from string "Location" to type 'Integer' is not valid


Hoping someone can help me. This should be something simple and basic but for some reason I just can't figure it out!

I created a class:
Private Class MasterData
Public mkt As String = "--"
Public zipCol As Integer = 0
Public width As String = "--"
Public value As String = "--"
Public setColumn As Integer = 0
Public setWidth As String = "--"
Public setPunch As String = "--"
End Class


Set up a list:
Private masterList As New List(Of MasterData)

Then when I try to read a file into the list, I get the error 'String "Location" to type 'Integer is not valid' on the line .zipCol = field(1) of the below code.

Do While masterRdr.Peek() >= 0
Dim masterRec As String = masterRdr.ReadLine
Dim field() As String = masterRec.Split(","c)

Dim thisMasterRec As New MasterData
With thisMasterRec
.mkt = field(0)
.zipCol = field(1)
.width = field(2)
.value = field(3)
.setColumn = field(4)
.setWidth = field(5)
.setPunch = field(6)
End With

masterList.Add(thisMasterRec)

Loop

masterRdr.Close()

Can anyone tell me what I'm doing wrong? This is making me crazy.

Thanks!
Joni
Reply With Quote
  #2  
Old 01-29-2015, 04:37 PM
HappyJoni's Avatar
HappyJoni HappyJoni is offline
Centurion
 
Join Date: Jun 2003
Location: New Jersey
Posts: 169
Default

Nevermind... I finally figured it out!

The first line of the CSV file I was reading had headers, one of the headers was labeled 'Location' which is obviously not an integer - lol

Boy do I feel stupid!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
 
Conversion from string "Location" to type 'Integer' is not valid
Conversion from string "Location" to type 'Integer' is not valid
 
-->