Solved

'System.FormatException...........Convert from String to Boolean

Posted on 2004-09-03
4
217 Views
Last Modified: 2010-04-23
I am reading data from a flat file.  The data in the field is a 0.  I am reading it in as a String value because if the data does not exist, the fill the location with a blank.  I then try to covert it to a boolean value but get a system.format problem.  What could be causing this problem.

Thanks
Kenny


Here is the code


Dim migrant As String
 migrant = Val(Mid(strLine, 102, 1))
  migrant = Convert.ToBoolean(migrant)
0
Comment
Question by:kwh3856
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11974376
you cant convert a 1/0 to a boolean ...

instead use

dim foo as integer = Convert.ToInt(migrant)
dim val as boolean = (foo = 1)
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11974382
or you can just put in an ifstatement if thats clearer to you ...

dim  val as boolean = false
if migrant = "1" then
    val = true
end if
0
 

Author Comment

by:kwh3856
ID: 11974421
Once again.....THANK YOU..


Thanks
Kenny
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11974425
anytime, let me know if you need anything further.

Cheers,

Greg
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question