473,412 Members | 3,015 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,412 software developers and data experts.

int.parse

Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks

Nov 19 '05 #1
7 2900
sara wrote:
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks


What is the value of string "y"? The error says that it
doesn't look like a correct number.

Just a sidenote: The "Text" property of (I'm guessing) a TextBox
already gives a string value. No need to use ToString() there.

--
Hans Kesting
Nov 19 '05 #2
Thanks Hans
let say y=4;

"Hans Kesting" wrote:
sara wrote:
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks


What is the value of string "y"? The error says that it
doesn't look like a correct number.

Just a sidenote: The "Text" property of (I'm guessing) a TextBox
already gives a string value. No need to use ToString() there.

--
Hans Kesting

Nov 19 '05 #3
y can't be = 4 because it's a string....

if y = "4"; then Int.Parse(y) should work...so it's probably something
other than "4"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sara" <sa**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
Thanks Hans
let say y=4;

"Hans Kesting" wrote:
sara wrote:
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks


What is the value of string "y"? The error says that it
doesn't look like a correct number.

Just a sidenote: The "Text" property of (I'm guessing) a TextBox
already gives a string value. No need to use ToString() there.

--
Hans Kesting

Nov 19 '05 #4
hi
you can also try
Convert.ToInt32(y)

regards
Ansil
Trivandrum

"sara" wrote:
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks

Nov 19 '05 #5
From where comes y ?

You get the text in the Bind variable but you try to parse y ???

Patrice

--

"sara" <sa**@discussions.microsoft.com> a écrit dans le message de
news:17**********************************@microsof t.com...
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks

Nov 19 '05 #6
Ansil

Convert.ToInt32 calls Int32.Parse

public sealed class Convert
{
public int ToInt32( string value )
{
if ( value == null ) return 0;
return Int32.Parse( value );
}
}

bill
"Ansil MCAD" <An*******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
hi
you can also try
Convert.ToInt32(y)

regards
Ansil
Trivandrum

"sara" wrote:
Hi to all
i have
string y;
int x=int.parse(y);
when i run the application this exeption is trewn
///////////////////////////////////////
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 106: string Bind=txtBimsID.Text.ToString();
Line 107: //////////////////////////////////
Line 108: int Ax=int.Parse(y);

Plz any help
Thanks

Nov 19 '05 #7
In addition, other characters in the string may also mess up the parsing.
For instance, suppose that you have y=" 4 ". Although that does look like
the number four, it has spaces around it which might cause parse problems.
If the user is entering this information in a textbox, then you might assume
the data is bad since the user could enter anything and you might have to
clean it up before parsing it.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:u3*************@TK2MSFTNGP15.phx.gbl...
y can't be = 4 because it's a string....

if y = "4"; then Int.Parse(y) should work...so it's probably something
other than "4"

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"sara" <sa**@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
Thanks Hans
let say y=4;

"Hans Kesting" wrote:
sara wrote:
> Hi to all
> i have
> string y;
> int x=int.parse(y);
> when i run the application this exeption is trewn
> ///////////////////////////////////////
> Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information about > the error and where it originated in the code.
>
> Exception Details: System.FormatException: Input string was not in a correct > format.
>
> Source Error:
>
> Line 106: string Bind=txtBimsID.Text.ToString();
> Line 107: //////////////////////////////////
> Line 108: int Ax=int.Parse(y);
>
> Plz any help
> Thanks
>
>
>

What is the value of string "y"? The error says that it
doesn't look like a correct number.

Just a sidenote: The "Text" property of (I'm guessing) a TextBox
already gives a string value. No need to use ToString() there.

--
Hans Kesting


Nov 19 '05 #8

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

Similar topics

22
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
3
by: Jon Davis | last post by:
The date string: "Thu, 17 Jul 2003 12:35:18 PST" The problem: // this fails on PST DateTime myDate = DateTime.Parse("Thu, 17 Jul 2003 12:35:18 PST"); Help? Jon
3
by: Mark | last post by:
How do you parse a currency string to a decimal? I'd like to avoid having to parse the number out, removing the $ manually. That sounds like a hack. There are times that this string will be...
14
by: Jon Davis | last post by:
I have put my users through so much crap with this bug it is an absolute shame. I have a product that reads/writes RSS 2.0 documents, among other things. The RSS 2.0 spec mandates an en-US style...
3
by: Bob Rundle | last post by:
I would like to get something like this to work... Type t = FindMyType(); // might be int, float, double, etc string s = "1233"; object v = t.Parse(s); This doesn't work of couse, Parse is...
3
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
2
by: Samuel R. Neff | last post by:
I'm using a quasi open-source project and am running into an exception in double.Parse which is effectively this: double.Parse(double.MinValue.ToString()) System.OverflowException: Value was...
3
by: Peter Duniho | last post by:
I'm sure there's a good explanation for this, but I can't figure it out. I tried using DateTime.Parse() with a custom DateTimeFormatInfo instance, in which I'd replaced the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.