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
409 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now