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
410 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

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…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 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