Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
419 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

877 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