473,244 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

System.InavlidCastException Error

This problably has a very simple explanation but it is totally perplexing me.
I have the following code...

Dim CompletelyUsed As String
CompletelyUsed = Me.txtCompletelyUsed.Text

Select Case CompletelyUsed
Case "Y" Or "y"
Do 'Do something here
Case "N" Or "n"
Do... 'Do something here
End Select
The problem is that when the Select Case statement is executed I get the
following error: "System.InavlidCastException: Cast from string "(the value
of Completelyused)" to type 'Long' is not valid. --->
System.FormatException: Input string was not in a correct format."

Could someone please help me understand why this error is occuring? Thanks.
Jul 21 '05 #1
2 1129
Because you are performing an Or opperation on two strings. Try this

Case "Y", "y"

Case "N", "n"

"MrMike" <Mr****@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
This problably has a very simple explanation but it is totally perplexing
me.
I have the following code...

Dim CompletelyUsed As String
CompletelyUsed = Me.txtCompletelyUsed.Text

Select Case CompletelyUsed
Case "Y" Or "y"
Do 'Do something here
Case "N" Or "n"
Do... 'Do something here
End Select
The problem is that when the Select Case statement is executed I get the
following error: "System.InavlidCastException: Cast from string "(the
value
of Completelyused)" to type 'Long' is not valid. --->
System.FormatException: Input string was not in a correct format."

Could someone please help me understand why this error is occuring?
Thanks.

Jul 21 '05 #2
That's the problem! Thanks for your help - I knew it had to be something
simple.

"JohnFol" wrote:
Because you are performing an Or opperation on two strings. Try this

Case "Y", "y"

Case "N", "n"

"MrMike" <Mr****@discussions.microsoft.com> wrote in message
news:07**********************************@microsof t.com...
This problably has a very simple explanation but it is totally perplexing
me.
I have the following code...

Dim CompletelyUsed As String
CompletelyUsed = Me.txtCompletelyUsed.Text

Select Case CompletelyUsed
Case "Y" Or "y"
Do 'Do something here
Case "N" Or "n"
Do... 'Do something here
End Select
The problem is that when the Select Case statement is executed I get the
following error: "System.InavlidCastException: Cast from string "(the
value
of Completelyused)" to type 'Long' is not valid. --->
System.FormatException: Input string was not in a correct format."

Could someone please help me understand why this error is occuring?
Thanks.


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DM | last post by:
Get this error when I try to run any ASP.NET web app from Visual Studio on my Win2K PC. Anyone seen this before ? BC32400: Class 'CLSID_CorSymWriter' could not be created: System Error...
1
by: Martin Honnen | last post by:
With both .NET 1.0 and 1.1 I have found the following strange behaviour where System.Xml.XmlDocument.LoadXml doesn't throw an error when parsing a text node with a character reference to an invalid...
8
by: A P | last post by:
Hi! I'm using ASP.Net Web Matrix on my PC and wanting to publish the files to our server. I try to copy (thru explorer) the files but it didn't work! I receive Runtime Error: Server Error...
5
by: petro | last post by:
Hello all, My asp.net web application works on my machine but I get the following error on our test web server, There is only one oracle home on the test server. Does anyone know how to resolve...
2
by: MrMike | last post by:
This problably has a very simple explanation but it is totally perplexing me. I have the following code... Dim CompletelyUsed As String CompletelyUsed = Me.txtCompletelyUsed.Text Select Case...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
0
by: nicomp | last post by:
I created a Web Service: I imported System.Data.SqlClient so I could access SQL server tables programmatically. The web service builds and deploys with no problems. When I try to add the...
2
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.