Solved

Cast from string " " to type 'Double' is not valid...........Trying to convert a string to a boolean value

Posted on 2004-09-08
3
414 Views
Last Modified: 2012-08-14
I am reading a flat text file with a field that has a blank.  I need to covert the string to a boolean value.  

Here is the error message

An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll

Additional information: Cast from string " " to type 'Double' is not valid.


Here is the code

Dim tmip As String
tmip = Mid(strLine, 152, 1)

If tmip = 0 Or "" Then
                tmip = False
            Else
                tmip = True
End If

The actual value when you look at the variable is a ""

Any help is greatly appreciated.

Thanks
Kenny



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
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
planocz earned 500 total points
ID: 12007124
Try this...

Dim tmip As String
if tmip.substring(152, 1).tostring = "" elseor tmip.substring(152, 1).tostring = 0 then
  tmip = false
Else
  tmip = true
End If
0
 

Author Comment

by:kwh3856
ID: 12007248
Thanks for the help.


Kenny
0
 
LVL 27

Expert Comment

by:planocz
ID: 12007313
glad to help, just call any time. :)
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…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

622 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